Executes derivative reactions for a Media and Node.

@param string $reaction_type
Reaction type.
@param \Drupal\node\NodeInterface $node
Node to pass to reaction.
@param \Drupal\media\MediaInterface $media
Media to evaluate contexts.
435214
public function executeDerivativeReactions($reaction_type, NodeInterface $node, MediaInterface $media) {
    $provider = new MediaContextProvider($media);
    $provided = $provider->getRuntimeContexts([]);
    $this->contextManager->evaluateContexts($provided);

    // Fire off index reactions.
    foreach ($this->contextManager->getActiveReactions($reaction_type) as $reaction) {
      $reaction->execute($node);
    }
  }
172912
public function apply(NodeInterface $node, array $context)
    {
        $context['node'] = $node;

        // Check if this template should be applied at all
        if (!$this->isApplicable($context)) {
            return;
        }
        $this->setProperties($node, $context);

        // Create child nodes if applicable
        /** @var Template $childNodeTemplate */
        foreach ($this->childNodes as $childNodeTemplate) {
            $childNodeTemplate->createOrFetchAndApply($node, $context);
        }

        $this->emitNodeTemplateApplied($node, $context, $this->options);
    }
1014522
protected function _process()
	{
		$this->_msg('Adding product media performance data', 0);


		$context = $this->_getContext();

		$mediaManager = MShop_Media_Manager_Factory::createManager( $context );
		$mediaTypeManager = $mediaManager->getSubManager( 'type' );

		$expr = array();
		$search = $mediaTypeManager->createSearch();
		$expr[] = $search->compare('==', 'media.type.domain', 'product');
		$expr[] = $search->compare('==', 'media.type.code', 'default');
		$search->setConditions( $search->combine( '&&', $expr ) );
		$types = $mediaTypeManager->searchItems($search);

		if ( ($mediaTypeItem = reset($types)) === false) {
			throw new Exception('Media type item not found');
		}


		$productManager = MShop_Product_Manager_Factory::createManager( $context );
		$productListManager = $productManager->getSubManager( 'list' );
		$productListTypeManager = $productListManager->getSubManager( 'type' );

		$expr = array();
		$search = $productListTypeManager->createSearch();
		$expr[] = $search->compare('==', 'product.list.type.domain', 'media');
		$expr[] = $search->compare('==', 'product.list.type.code', 'default');
		$search->setConditions( $search->combine( '&&', $expr ) );
		$types = $productListTypeManager->searchItems($search);

		if ( ($productListTypeItem = reset($types)) === false) {
			throw new Exception('Product list type item not found');
		}

		$expr = array();
		$search = $productListTypeManager->createSearch();
		$expr[] = $search->compare('==', 'product.list.type.domain', 'media');
		$expr[] = $search->compare('==', 'product.list.type.code', 'download');
		$search->setConditions( $search->combine( '&&', $expr ) );
		$types = $productListTypeManager->searchItems($search);

		if ( ($downloadListTypeItem = reset($types)) === false) {
			throw new Exception('Product list type item not found');
		}


		$mediaItem = $mediaManager->createItem();
		$mediaItem->setTypeId( $mediaTypeItem->getId() );
		$mediaItem->setLanguageId( null );
		$mediaItem->setDomain( 'product' );
		$mediaItem->setMimeType( 'image/jpeg' );
		$mediaItem->setStatus( 1 );

		$downloadItem = $mediaManager->createItem();
		$downloadItem->setTypeId( $mediaTypeItem->getId() );
		$downloadItem->setLanguageId( null );
		$downloadItem->setDomain( 'product' );
		$downloadItem->setMimeType( 'application/pdf' );
		$downloadItem->setLabel( 'PDF download' );
		$downloadItem->setPreview( 'unitperf/download-preview.jpg' );
		$downloadItem->setUrl( 'unitperf/download.pdf' );
		$downloadItem->setStatus( 1 );

		$mediaManager->saveItem( $downloadItem );


		$listItem = $productListManager->createItem();
		$listItem->setTypeId( $productListTypeItem->getId() );
		$listItem->setDomain( 'media' );

		$downloadListItem = $productListManager->createItem();
		$downloadListItem->setTypeId( $downloadListTypeItem->getId() );
		$downloadListItem->setRefId( $downloadItem->getId() );
		$downloadListItem->setDomain( 'media' );
		$downloadListItem->setPosition( 0 );


		$search = $productManager->createSearch();
		$search->setSortations( array( $search->sort( '+', 'product.id' ) ) );


		$this->_txBegin();

		$start = $pos = 0;

		do
		{
			$result = $productManager->searchItems( $search );

			foreach ( $result as $id => $item )
			{
				$mediaItem->setId( null );
				$mediaItem->setLabel( '1. picture for ' . $item->getLabel() );
				$mediaItem->setPreview( 'unitperf/' . ( ($pos + 0) % 4 + 1 ) . '.jpg' );
				$mediaItem->setUrl( 'unitperf/' . ( ($pos + 0) % 4 + 1 ) . '-big.jpg' );
				$mediaManager->saveItem( $mediaItem );

				$listItem->setId( null );
				$listItem->setParentId( $id );
				$listItem->setRefId( $mediaItem->getId() );
				$listItem->setPosition( 0 );
				$productListManager->saveItem( $listItem, false );


				$mediaItem->setId( null );
				$mediaItem->setLabel( '2. picture for ' . $item->getLabel() );
				$mediaItem->setPreview( 'unitperf/' . ( ($pos + 1) % 4 + 1 ) . '.jpg' );
				$mediaItem->setUrl( 'unitperf/' . ( ($pos + 1) % 4 + 1 ) . '-big.jpg' );
				$mediaManager->saveItem( $mediaItem );

				$listItem->setId( null );
				$listItem->setParentId( $id );
				$listItem->setRefId( $mediaItem->getId() );
				$listItem->setPosition( 1 );
				$productListManager->saveItem( $listItem, false );


				$mediaItem->setId( null );
				$mediaItem->setLabel( '3. picture for ' . $item->getLabel() );
				$mediaItem->setPreview( 'unitperf/' . ( ($pos + 2) % 4 + 1 ) . '.jpg' );
				$mediaItem->setUrl( 'unitperf/' . ( ($pos + 2) % 4 + 1 ) . '-big.jpg' );
				$mediaManager->saveItem( $mediaItem );

				$listItem->setId( null );
				$listItem->setParentId( $id );
				$listItem->setRefId( $mediaItem->getId() );
				$listItem->setPosition( 2 );
				$productListManager->saveItem( $listItem, false );


				$mediaItem->setId( null );
				$mediaItem->setLabel( '4. picture for ' . $item->getLabel() );
				$mediaItem->setPreview( 'unitperf/' . ( ($pos + 3) % 4 + 1 ) . '.jpg' );
				$mediaItem->setUrl( 'unitperf/' . ( ($pos + 3) % 4 + 1 ) . '-big.jpg' );
				$mediaManager->saveItem( $mediaItem );

				$listItem->setId( null );
				$listItem->setParentId( $id );
				$listItem->setRefId( $mediaItem->getId() );
				$listItem->setPosition( 3 );
				$productListManager->saveItem( $listItem, false );


				$pos++;


				$downloadListItem->setId( null );
				$downloadListItem->setParentId( $id );
				$productListManager->saveItem( $downloadListItem, false );
			}

			$count = count( $result );
			$start += $count;
			$search->setSlice( $start );
		}
		while( $count == $search->getSliceSize() );

		$this->_txCommit();


		$this->_status( 'done' );
	}
190345
protected function processMediaImage($node)
    {
        $media = $node->getChild('media');

        if ($media != null) {
            $filename = $media->getAttribute('file');
            $url = $media->getAttribute('url');

            //save thumbnail
            file_put_contents($this->dataFolder.Constants::MEDIA_FOLDER.DIRECTORY_SEPARATOR.'thumb_'.$filename, $media->getData());
            //download and save original
            file_put_contents($this->dataFolder.Constants::MEDIA_FOLDER.DIRECTORY_SEPARATOR.$filename, file_get_contents($url));
        }
    }
201019
public function streamMediaAction(ResourceNode $node)
    {
        $collection = new ResourceCollection(array($node));
        $this->checkAccess('OPEN', $collection);

        // free the session as soon as possible
        // see https://github.com/claroline/CoreBundle/commit/7cee6de85bbc9448f86eb98af2abb1cb072c7b6b
        $this->get('session')->save();

        $file = $this->get('claroline.manager.resource_manager')->getResourceFromNode($node);
        $path = $this->container->getParameter('claroline.param.files_directory').DIRECTORY_SEPARATOR
            .$file->getHashName();

        $response = new BinaryFileResponse($path);
        $response->headers->set('Content-Type', $node->getMimeType());

        return $response;
    }
178996
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $this->executeOrSimulate($node, $application, $deployment, $options);
    }
1179291
public function apply(AbstractNode $node)
    {
        if (preg_match('([A-Za-z0-9]+Bridge$)', $node->getName()) === 0 ||
            preg_match('#.*\\\\Dependency\\\\.*#', $node->getNamespaceName()) === 0 ||
            !$node instanceof ClassNode) {
            return;
        }

        $classNodeInterfaces = $node->getInterfaces();

        if (!$classNodeInterfaces->count()) {
            $message = sprintf(
                'The bridge `%s` doesn\'t  have any interfaces.',
                $node->getName()
            );
            $this->addViolation($node, [$message]);

            return;
        }

        $firstInterface = $classNodeInterfaces[0];

        $interfaceNode = new InterfaceNode($firstInterface);

        $this->verifyClass($node, $interfaceNode);
        $this->verifyInterface($node, $interfaceNode);
    }
299896
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Param || ! $parent instanceof FunctionModelInterface) {
            throw new Exception('ParameterNodeParser is made to parse a function parameter node');
        }

        $parameter = new ParameterModel();
        $parameter->setParentNode($parent);
        $parameter->setName($node->var->name);
        $parameter->setIsVariadic($node->variadic);

        if ($node->type !== null) {
            $this->typeNodeParser->invoke($node->type, $parameter);
        }
        if ($node->default !== null) {
            $this->valueNodeParser->invoke($node->default, $parameter);
        }

        $parent->addParameter($parameter);
    }
1065773
public function executeNodeReactions($reaction_type, NodeInterface $node) {
    $provider = new NodeContextProvider($node);
    $provided = $provider->getRuntimeContexts([]);
    $this->contextManager->evaluateContexts($provided);

    // Fire off index reactions.
    foreach ($this->contextManager->getActiveReactions($reaction_type) as $reaction) {
      $reaction->execute($node);
    }
  }
1202250
public function indexXDT( &$types, &$node, &$element )
	{
		$xbrldtAttributes = $node->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_XBRLDT ] );
		if ( property_exists( $xbrldtAttributes, 'typedDomainRef' ) )
		{
			$element['typedDomainRef'] = (string) $xbrldtAttributes->typedDomainRef;
		}

		if ( ! empty( $element['substitutionGroup'] ) )
		{
			$id = $element['id'];
			$name = $element['name'];

			if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xbrldtDimensionItem ) ) )
			{
				$this->elementDimensions[] = $name;
			}
			else if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xbrldtHypercubeItem ) ) )
			{
				$this->elementHypercubes[] = $name;
			}
			else if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xlArc ) ) )
			{
				$this->elementArcTypes[] = $name;
			}
			else if ( $types->resolveToSubstitutionGroup( $element['substitutionGroup'], array( XBRL_Constants::$xlExtended ) ) )
			{
				$this->elementLinkTypes[] = $name;
			}
			// else if ( $element['type'] == XBRL_Constants::$enumItemType || $element['type'] == XBRL_Constants::$enumSetItemType )
			else if ( $types->resolvesToBaseType( $element['type'], array( XBRL_Constants::$enumItemType, XBRL_Constants::$enumSetItemType ), false ) )
			{
				// Record that this element is an extensible enumeration concept
				$this->enumerations[  $id ] = $id;

				// Make sure there is a linkrole and domain attribute
				$enumAttributes = $node->attributes( XBRL_Constants::$standardPrefixes[ STANDARD_PREFIX_ENUMERATIONS ] );

				if ( property_exists( $enumAttributes, 'domain' ) )
				{
					$element['enumDomain'] = (string)$enumAttributes['domain'];
				}
				else
				{
					if ( $this->isValidating() )
					{
						$this->log()->taxonomy_validation( "Extensible enumerations", "The extensible concept does not include a domain",
							array(
								'id' => $id,
								'name' => $name,
								'type' => $element['substitutionGroup'],
								'error' => 'enumte:MissingDomainError'
							)
						);
					}
				}

				if ( property_exists( $enumAttributes, 'linkrole' ) )
				{
					$element['enumLinkrole'] = (string)$enumAttributes['linkrole'];
				}
				else
				{
					if ( $this->isValidating() )
					{
						$this->log()->taxonomy_validation( "Extensible enumerations", "The extensible concept does not include a linkrole",
							array(
								'id' => $id,
								'name' => $name,
								'type' => $element['substitutionGroup'],
								'error' => 'enumte:MissingLinkRoleError'
							)
						);
					}
				}

				$element['enumHeadUsable'] = property_exists( $enumAttributes, 'headUsable' )
					? filter_var( $enumAttributes['headUsable'], FILTER_VALIDATE_BOOLEAN )
					: false;
			}
		}

	}
1326898
private function triggerActionEvent($instance, $action, $type = 'before')
    {
        if (method_exists($instance, $type . ucfirst($action))) {
            call_user_func([$instance, $type . ucfirst($action)]);
        }
    }
1115002
public function registerNodeChange(NodeInterface $node)
    {
        if (in_array($node->getIdentifier(), $this->tagsToFlush)) {
            return;
        }
        if (!$node->getNodeType()->isOfType('Neos.Neos:Document')) {
            return;
        }
        $this->tagsToFlush[] = $node->getIdentifier();
    }
664201
protected function configureImage(NodeInterface $node, NodeType $nodeType, array $config = [])
    {
        $this->configureCreateAssistanceChildNodes($node, $nodeType, $config);

        switch ($node->getParent()->getNodeType()->getName()) {
            // Image slider: enable caption by default
            case 'M12.Foundation:Orbit':
                if (!$node->getProperty('hasCaption')) {
                    $node->setProperty('hasCaption', true);
                    $node->setProperty('caption', 'Image caption');
                }
                break;
        }
    }
932565
public function updateSourceField(
    MediaInterface $media,
    $resource,
    $mimetype
  ) {
    $source_field = $this->getSourceFieldName($media->bundle());
    $file = $this->getSourceFile($media);

    // Update it.
    $this->updateFile($file, $resource, $mimetype);
    $file->save();

    // Set fields provided by type plugin and mapped in bundle configuration
    // for the media.
    foreach ($media->bundle->entity->getFieldMap() as $source => $destination) {
      if ($media->hasField($destination) && $value = $media->getSource()->getMetadata($media, $source)) {
        $media->set($destination, $value);
      }
      // Ensure width and height are updated on File reference when it's an
      // image. Otherwise you run into scaling problems when updating images
      // with different sizes.
      if ($source == 'width' || $source == 'height') {
        $media->get($source_field)->first()->set($source, $value);
      }
    }

    $media->save();
  }
1044966
public function filterChildNodesForTreeAction(Node $node, $term, $nodeType)
    {
        $nodeTypes = strlen($nodeType) > 0 ? [$nodeType] : array_keys($this->nodeTypeManager->getSubNodeTypes('Neos.Neos:Document', false));
        $context = $node->getContext();
        if ($term !== '') {
            $nodes = $this->nodeSearchService->findByProperties($term, $nodeTypes, $context, $node);
        } else {
            $nodes = [];
            $nodeDataRecords = $this->nodeDataRepository->findByParentAndNodeTypeRecursively($node->getPath(), implode(',', $nodeTypes), $context->getWorkspace(), $context->getDimensions());
            foreach ($nodeDataRecords as $nodeData) {
                $matchedNode = $this->nodeFactory->createFromNodeData($nodeData, $context);
                if ($matchedNode !== null) {
                    $nodes[$matchedNode->getPath()] = $matchedNode;
                }
            }
        }
        $this->view->assignFilteredChildNodes(
            $node,
            $nodes
        );
    }
337778
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        Assert::isInstanceOf($application, Flow::class, sprintf('Flow application needed for PublishResourcesTask, got "%s"', get_class($application)));

        if ($application->getVersion() >= '3.0') {
            $targetPath = $deployment->getApplicationReleasePath($application);
            $this->shell->executeOrSimulate($application->buildCommand($targetPath, 'resource:publish'), $node, $deployment);
        }
    }
535509
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\Class_ || ! $parent instanceof PhpFileModelInterface) {
            throw new Exception('ClassNodeParser is made to parse a class node');
        }
        $class = new ClassModel();
        $class->setParentNode($parent);
        $class->setName(ClassLikeNameHelper::getName($node));
        $class->setIsAbstract($node->isAbstract());
        $class->setIsFinal($node->isFinal());
        $parent->addConcreteUse($parent->getFullNameFor($class->getName()), $class->getName());

        if (($documentation = $node->getDocComment()) !== null) {
            $this->documentationNodeParser->invoke($documentation, $class);
        }

        $this->parseSubNodes($node->stmts, $class);

        $parent->addClass($class);
    }