Пример #1
0
Файл: Part.php Проект: noose/zf2
    /**
     * __construct(): defined by Route interface.
     *
     * @see    Route::__construct()
     * @param  mixed $options
     * @return void
     */
    public function __construct($options = null)
    {
        parent::__construct($options);
        
        if ($options instanceof Config) {
            $options = $options->toArray();
        } elseif ($options instanceof Traversable) {
            $options = iterator_to_array($options);
        }

        if (!is_array($options)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Expected an array or Traversable; received "%s"',
                (is_object($options) ? get_class($options) : gettype($options))
            ));
        }
        
        if (!isset($options['route']) || !$options['route'] instanceof Route) {
            throw new Exception\InvalidArgumentException('Route not defined or not an instance of Route');
        }

        $this->route        = $options['route'];
        $this->mayTerminate = (isset($options['may_terminate']) && $options['may_terminate']);
        
        if (isset($options['child_routes'])) {
            $this->childRoutes = $options['child_routes'];
        }
    }