public function scan($directory, array $options = array())
    {
        set_time_limit(0);

        $options += array(
            'sort' => null,
            'order' => null,
            'filter_key' => null,
            'filter_value' => null
        );

        $result = null;
        $this->hook->attach('module.file_manager.scan.before', $directory, $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $filters = $this->getFilters();
        $iterator = new Filter(new FilesystemIterator($directory), $options, $filters);

        if (!empty($options['count'])) {
            return iterator_count($iterator);
        }

        if (!empty($options['limit'])) {
            list($page, $limit) = $options['limit'];
            $iterator = new LimitIterator($iterator, $page, $limit);
        }

        $result = iterator_to_array($iterator);
        $this->sort($result, $options['sort'], $options['order']);

        $this->hook->attach('module.file_manager.scan.after', $directory, $options, $result, $this);
        return $result;
    }