@param                  $actionsCollectionOrMap
@param ActionDescriptor $descriptor

@return $this
@throws InvalidArgumentException
@throws RuntimeException
769130
private function addAction(&$actionsCollectionOrMap, ActionDescriptor $descriptor)
    {
        $descriptorId = $descriptor->getId();
        $action = $this->getAction($descriptorId);
        if (null !== $action) {
            $errMsg = sprintf('Действие с id %s уже существует', $descriptorId);
            throw new InvalidArgumentException($errMsg);
        }

        if ($actionsCollectionOrMap instanceof SplObjectStorage) {
            $actionsCollectionOrMap->attach($descriptor);
        } elseif (is_array($actionsCollectionOrMap)) {
            $actionsCollectionOrMap[$descriptorId] = $descriptor;
        }

        return $this;
    }
597449
public function setCollector(ResourceCollectorInterface $collector)
    {
        $this->collector = $collector;

        if ($this->loader) {
            if ($this->loader instanceof ResourceAwareInterface) {
                $this->loader->setResourceCollector($collector);
            }

            if ($this->loader instanceof DelegatingLoader) {
                $resolver = $this->loader->getResolver();

                if ($resolver instanceof ResourceAwareInterface) {
                    $resolver->setResourceCollector($collector);
                }
            }
        }
    }
830338
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
	{
		$this->eventDispatcher = $eventDispatcher;
		$this->twig->setEventDispatcher($eventDispatcher);
	}
90766
public function generate(CollectionInterface $options, ServiceLocatorInterface $locator)
    {
        $rocketeerFolder = $options->get('rocketeer_folder', '.rocketeer');
        $templateData = $this->collectDataFromInputForTemplate($options);
        $sourcePath = $options->get('source', dirname(dirname(__DIR__)) . '/templates/rocketeer');
        $destinationPath = $locator->get('pathManager')->getAbsolutePath("/{$rocketeerFolder}");

        $copier = $this->getAndConfigurateCopierFromLocator($locator, $templateData);
        $source = new Directory($sourcePath);
        $destination = new Directory($destinationPath);

        if ($destination->isExists()) {
            throw new InvalidArgumentException(
                'Directory ' . $destination->getPathname() . ' already exists'
            );
        }

        $copier->copyDir($source, $destination);

        if ($options->get('gitignore_inject', false)) {
            $gitignorePath = $locator->get('pathManager')->getAbsolutePath(
                $options->get('gitignore_path', '.gitignore')
            );
            $gitignoreData = '.rocketeer/logs';
            if (!file_exists($gitignorePath)) {
                file_put_contents($gitignorePath, $gitignoreData);
            } elseif (mb_strpos(file_get_contents($gitignorePath), $gitignoreData) === false) {
                file_put_contents($gitignorePath, "\r\n\r\n" . $gitignoreData, FILE_APPEND);
            }
        }

        if ($options->get('phar_inject', false)) {
            $pharUrl = $options->get('phar_url', 'http://rocketeer.autopergamene.eu/versions/rocketeer.phar');
            $pharPath = $locator->get('pathManager')->getAbsolutePath(
                'rocketeer.phar'
            );
            $fh = @fopen($pharUrl, 'r');
            if ($fh === false) {
                throw new InvalidArgumentException(
                    "Can't open {$pharUrl} for download"
                );
            }
            file_put_contents($pharPath, $fh);
            fclose($fh);
        }
    }
255334
public function withCollection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [], array $headers = [])
    {
        $resource = new Collection($data, $transformer, $resourceKey);

        foreach ($meta as $metaKey => $metaValue) {
            $resource->setMetaValue($metaKey, $metaValue);
        }

        if (!is_null($cursor)) {
            $resource->setCursor($cursor);
        }

        $rootScope = $this->manager->createData($resource);

        return $this->withArray($rootScope->toArray(), $headers);
    }
343656
protected function convertToArrayDescriptor($descriptor)
    {
        $arrayDescriptor = new CollectionDescriptor('array');
        $arrayDescriptor->setTypes(array($descriptor));
        $arrayDescriptor->setKeyTypes(array('mixed'));

        return $arrayDescriptor;
    }
144245
public function collection($namespace)
    {
        if (!class_exists($namespace)) {
            throw new InvalidRouterCollectionException('Route Collection Class $namespace doesn\'t exists');
        }

        $routeCollection = $this->getContainer()->make($namespace);

        return $routeCollection->setRouter($this);
    }
914050
public function getActionByName(WorkflowDescriptor $wf, $actionName)
    {
        $actionName = (string)$actionName;

        foreach ($wf->getGlobalActions() as $actionDescriptor) {
            if ($actionName === $actionDescriptor->getName()) {
                return $actionDescriptor;
            }
        }

        foreach ($wf->getSteps() as $stepDescriptor) {
            $actions = $stepDescriptor->getActions();
            foreach ($actions as $actionDescriptor) {
                if ($actionName === $actionDescriptor->getName()) {
                    return $actionDescriptor;
                }
            }
        }

        foreach ($wf->getInitialActions() as $actionDescriptor) {
            if ($actionName === $actionDescriptor->getName()) {
                return $actionDescriptor;
            }
        }

        return null;
    }
573195
protected function retrieveIndexOfFieldDescriptor(
        FieldDescriptorInterface $fieldDescriptor,
        array $fieldDescriptors
    ) {
        foreach ($fieldDescriptors as $index => $other) {
            if ($fieldDescriptor->compare($other)) {
                return $index;
            }
        }

        return false;
    }
1118450
public static MethodDescriptor buildScriptableMethodDescriptor(
    Class actionClass, String methodName, String[] parameterNames, Class[] parameterTypes )
  {
    MethodDescriptor md = _buildMethodDescriptor( actionClass, methodName, parameterNames, parameterTypes, parameterTypes );
    makeScriptable( md );
    return md;
  }
1001715
public function setMapEntries(MapEntryCollection $mapEntries)
    {
        if (count($mapEntries) > 0) {
            $this->mapEntries = $mapEntries;
        } else {
            $msg = "A Mapping object must contain at least one MapEntry object, none given.";
            throw new InvalidArgumentException($msg);
        }
    }
302975
public function add( Descriptor $argDescriptor ) : Support
   {

      $this->_attributes[ $argDescriptor->getName() ] = $argDescriptor;

      return $this;

   }
1165193
public function addCollection(PermissionCollection $permissions)
    {
        if ($permissions->getObjectType() !== $this->getObjectType()) {
            throw new InvalidArgumentException('Mismating object types.');
        }

        foreach ($permissions->all() as $permission) {
            $this->add($permission);
        }

        return $this;
    }
77247
public function alias($alias, DescriptorInterface $prototype, $params = null, $actions = null)
    {
        $descriptor = clone $prototype;

        $descriptor->setParams($params)->setActions($actions)->setName($alias);

        $key                     = $this->makeKey($alias);
        $this->descriptors[$key] = $descriptor;

        return $descriptor;
    }
1186472
public function createParameters(PageDocumentDescriptor $descriptor)
    {
        $language = $descriptor->getLanguage();
        $parameters = ['_locale' => $descriptor->getLanguage()];

        $country = $this->countryCollection->findBy(
            function (Country $country) use ($language) {
                return $country->getLanguages()->contains($language);
            }
        );
        if ($country) {
            $parameters = $parameters + ['_country' => $country->getIdentifier()];
        }

        return $parameters;
    }
316834
public static function enrichVisitorArrayWithActions($visitorDetailsArray, $actionDetails = array())
    {
        $actionsLimit = (int)Config::getInstance()->General['visitor_log_maximum_actions_per_visit'];
        $visitorDetailsManipulators = self::getAllVisitorDetailsInstances();

        foreach ($visitorDetailsManipulators as $instance) {
            $instance->provideActionsForVisit($actionDetails, $visitorDetailsArray);
        }

        foreach ($visitorDetailsManipulators as $instance) {
            $instance->filterActions($actionDetails, $visitorDetailsArray);
        }

        usort($actionDetails, array('static', 'sortByServerTime'));

        $actionDetails = array_values($actionDetails);

        // limit actions
        if ($actionsLimit < count($actionDetails)) {
            $visitorDetailsArray['truncatedActionsCount'] = count($actionDetails) - $actionsLimit;
            $actionDetails = array_slice($actionDetails, 0, $actionsLimit);
        }

        foreach ($actionDetails as $actionIdx => &$actionDetail) {
            $actionDetail =& $actionDetails[$actionIdx];
            $nextAction = isset($actionDetails[$actionIdx+1]) ? $actionDetails[$actionIdx+1] : null;

            foreach ($visitorDetailsManipulators as $instance) {
                $instance->extendActionDetails($actionDetail, $nextAction, $visitorDetailsArray);
            }
        }

        $visitorDetailsArray['actionDetails'] = $actionDetails;

        return $visitorDetailsArray;
    }
278878
public function create(RequestDescriptor $descriptor)
    {
        $method = strtolower($descriptor->getMethod());

        if (!method_exists($this, $method)) {
            return $this->defaultRequest($descriptor);
        }

        return $this->$method($descriptor);
    }