Esempio n. 1
0
 /**
  * @param $content
  * @param $extensionName
  * @return array
  */
 public function findInContent($content, $extensionName)
 {
     try {
         $tokens = $this->tokenizer->getTokens($content);
     } catch (InvalidContentException $e) {
         $tokens = [];
     } catch (InvalidSyntaxException $e) {
         $tokens = [];
     }
     return $this->callFactory->createByTokens($extensionName, $tokens);
 }
 /**
  * @param $content
  * @return Dependency[]
  */
 public function findInContent($content)
 {
     $relations = [];
     try {
         $tokens = $this->tokenizer->getTokens($content);
     } catch (InvalidContentException $e) {
         $tokens = [];
     } catch (InvalidSyntaxException $e) {
         $tokens = [];
     }
     for ($i = 0; $i < count($tokens); $i++) {
         $token = $tokens[$i];
         if ($token->getType() == \Twig_Token::NAME_TYPE) {
             if ($token->getValue() == self::INCLUDE_TYPE || $token->getValue() == self::EXTEND_TYPE) {
                 $path = $tokens[$i + 1]->getValue();
                 if ($this->hasDependencyWith($relations, $path)) {
                     continue;
                 }
                 $relations[] = $this->dependencyFactory->create($path, $token->getValue());
             }
         }
     }
     return $relations;
 }