@param mixed          $object
@param string         $language
@param TokenInterface $token

@return array
189063
public function resolve($object, $language, TokenInterface $token)
    {
        if (!($object instanceof DomainObjectInterface)) {
            return array();
        }

        $permissionNames = array();

        if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
            if (!isset($this->superAdminPermissions[$token])) {
                $permissions = $this->permissionRegistry->get(get_class($object))->all();

                foreach ($permissions as $permission) {
                    $permissionNames[] = $permission->getName();
                }

                $this->superAdminPermissions[$token] = $permissionNames;
            }

            return $this->superAdminPermissions[$token];
        }

        if (!$this->authorizationChecker->isGranted(['permission' => 'VIEW', 'language' => $language], $object)) {
            return null;
        }

        $identity = HierarchicalObjectIdentity::fromDomainObject($object);
        $acl = $this->accessManager->findAcl($identity);

        $permissions = $acl->getEffectivePermissions($token, $language);

        foreach ($permissions as $permission) {
            $permissionNames[] = $permission->getName();
        }

        return $permissionNames;
    }
1302283
public function parse(Twig_Token $token)
    {
        $grammar = $this->getGrammar();
        if (!is_object($grammar)) {
            $grammar = self::parseGrammar($grammar);
        }

        $grammar->setParser($this->parser);
        $values = $grammar->parse($token);

        return $this->getNode($values, $token->getLine());
    }
19703
public function translateActivityToken($token, ComActivitiesActivityInterface $activity)
    {
        if (is_string($token))
        {
            $tokens = $this->getActivityTokens($activity);

            if (isset($tokens[$token])) {
                $token = $tokens[$token];
            }
        }

        if (!$token instanceof ComActivitiesActivityObjectInterface) {
            throw new RuntimeException('Invalid token');
        }

        $result = $token->getDisplayName();

        if ($token->isTranslatable())
        {
            if ($activity->getLocale() == $this->getLocaleFallback())
            {
                // Use decorator catalogue instead
                $this->_switchCatalogues();
                $result = $this->translate($result);
                $this->_switchCatalogues();
            } else $result = $this->translate($result);
        }

        return $result;
    }
1275442
public function parse(Token $token): string
    {
        $value = $token->getValue();
        if ('' === $value) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
        }

        return $this->tokenizer->detokenize(substr($value, 1));
    }
945645
private static function isBinaryOperator(TokenInterface $token): bool
    {
        return in_array($token->getType(), [
            TokenInterface::TYPE_OPERATOR_ASSIGNMENT,
            TokenInterface::TYPE_OPERATOR_COPY,
            TokenInterface::TYPE_OPERATOR_MODIFY,
            TokenInterface::TYPE_OPERATOR_REFERENCE,
        ]);
    }
1137842
public function translate($object, $locale)
    {
        $classStack = $this->getNamespacesFromClass(get_class($object));

        foreach ($classStack as $classNamespace) {
            if (!array_key_exists($classNamespace, $this->configuration)) {
                continue;
            }

            $configuration = $this->configuration[$classNamespace];
            $idGetter = $configuration['idGetter'];
            $entityId = $object->$idGetter();

            foreach ($configuration['fields'] as $fieldName => $fieldConfiguration) {
                $setter = $fieldConfiguration['setter'];
                $translation = $this
                    ->entityTranslationProvider
                    ->getTranslation(
                        $configuration['alias'],
                        $entityId,
                        $fieldName,
                        $locale
                    );

                if ($translation || !$this->fallback) {
                    $object->$setter($translation);
                }
            }
        }

        return $object;
    }
894687
public function parse(Token $token): ParameterValue
    {
        $value = $token->getValue();
        try {
            $paramKey = substr($value, 2, strlen($value) - 4);

            return new ParameterValue($paramKey);
        } catch (\TypeError $error) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token, 0, $error);
        }
    }
638726
public function parse(Token $token): FixtureMethodCallValue
    {
        parent::parse($token);

        $explodedValue = explode('->', $token->getValue());
        if (count($explodedValue) !== 2) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
        }

        $reference = $this->parser->parse($explodedValue[0]);
        $method = $this->parser->parse(
            sprintf(
                '<%s>',
                $explodedValue[1]
            )
        );

        if ($reference instanceof FixtureReferenceValue && $method instanceof FunctionCallValue) {
            return new FixtureMethodCallValue($reference, $method);
        }

        throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
    }
200964
public function parse(Token $token)
    {
        parent::parse($token);

        $values = preg_split('/->/', $token->getValue());
        if (2 !== count($values)) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
        }

        $fixture = $this->parser->parse($values[0]);
        $method = $this->parser->parse(sprintf('<%s>', $values[1]));

        try {
            return new FixtureMethodCallValue($fixture, $method);
        } catch (\TypeError $exception) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token, 0, $exception);
        }
    }
575131
public function parse(Token $token)
    {
        $value = $token->getValue();
        $fixtureId = substr($value, 1, strlen($value) - 2);
        if (false === $fixtureId) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
        }

        return FixtureMatchReferenceValue::createWildcardReference($fixtureId);
    }
716620
static function parseIdentifierList(array $tokens, &$i) {
    $list = array();
    while (TRUE) {
      $id = ParserUtil::nextSubstantialIncl($tokens, $i);
      if (T_STRING !== $id) {
        return FALSE;
      }
      $list[] = $tokens[$i][1];
      $id = ParserUtil::nextSubstantialExcl($tokens, $i);
      if (',' !== $id) {
        break;
      }
      ++$i;
    }
    return $list;
  }
370870
public function vote(TokenInterface $token, $object, array $attributes)
    {
        $result = VoterInterface::ACCESS_ABSTAIN;
        if (!$object instanceof FamilyInterface) {
            return $result;
        }
        if (VoterInterface::ACCESS_DENIED === $this->roleHierarchyVoter->vote($token, null, ['ROLE_DATA_MANAGER'])) {
            return VoterInterface::ACCESS_DENIED;
        }
        if (VoterInterface::ACCESS_GRANTED === $this->roleHierarchyVoter->vote($token, null, ['ROLE_DATA_ADMIN'])) {
            return VoterInterface::ACCESS_GRANTED;
        }
        $permissions = $this->extractPermissions($token);

        $result = VoterInterface::ACCESS_DENIED;
        foreach ($attributes as $attribute) {
            if (!$this->supportsAttribute($attribute)) {
                continue;
            }

            foreach ($permissions as $permission) {
                if ($permission->hasPermission($attribute) &&
                    $permission->getFamilyCode() === $object->getCode()
                ) {
                    return VoterInterface::ACCESS_GRANTED;
                }
            }
        }

        return $result;
    }
17734
public static function get_by_object_label_language($object, $label, \Skeleton\I18n\LanguageInterface $language, $auto_create = true) {
		$class_parents = class_parents($object);
		if ($class_parents === false OR count($class_parents) == 0) {
			$class = get_class($object);
		} else {
			$class = array_pop($class_parents);
		}

		if (self::trait_cache_enabled()) {
			try {
                $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
				$object = self::cache_get($key);
				return $object;
			} catch (\Exception $e) {}
        }

        $db = Database::Get();
		$data = $db->get_row('SELECT * FROM object_text WHERE classname=? AND object_id=? AND label=? AND language_id=?', [ $class, $object->id, $label, $language->id ]);

		if ($data === null) {
		    if (!$auto_create) {
			    throw new \Exception('Object text does not exists');
			} else {
				$requested = new self();
                $requested->object = $object;
				$requested->language_id = $language->id;
				$requested->label = $label;
				$requested->content = '';
				$requested->save();

				if (self::trait_cache_enabled()) {
                    $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
                    self::cache_set($key, $requested);
                }

                return $requested;
			}
		}

		$object_text = new self();
		$object_text->id = $data['id'];
		$object_text->details = $data;

		if (self::trait_cache_enabled()) {
            $key = $class . '_' . $object->id . '_' . $label . '_' . $language->name_short;
            self::cache_set($key, $object_text);
        }

		return $object_text;
	}
312630
public function translate($object)
    {
        $commandBaseNamespace = app()->getNamespace() . "Commands";
        $handlerBaseNamespace = app()->getNamespace(). "Handlers";

        $reflectionObject = new ReflectionClass($object);

        $commandNamespace = $this->getCommandNamespace($commandBaseNamespace, $reflectionObject);
        $command = $this->getCommandName($reflectionObject);

        $handler = str_replace('Command', 'CommandHandler', $command);


        if($commandNamespace !== $commandBaseNamespace) {
            $handlerNamespace = $handlerBaseNamespace . $commandNamespace . "\\" . $handler;

            $commandNamespace = $commandBaseNamespace .  $commandNamespace . "\\" . $command;
        }


        if(! class_exists($commandNamespace)) {
            throw new CommandNotFoundException("Command [ $command ] does not exist.");
        }

        if(! class_exists($handlerNamespace)) {
            throw new HandlerNotFoundException("Handler [ $handler ] does nto exist.");
        }

        return $handlerNamespace;
    }
489554
public function getSecurityIdentities(TokenInterface $token)
    {
        $sids = parent::getSecurityIdentities($token);

        if ($token->getUser() instanceof \BackBee\Security\User) {
            foreach ($token->getUser()->getGroups() as $group) {
                $securityIdentity = new UserSecurityIdentity($group->getObjectIdentifier(), ClassUtils::getRealClass($group));
                array_unshift($sids, $securityIdentity);
            }
        }

        return $sids;
    }
1185101
public static function getClassAnnotations($object)
	{
		$classReflection = new \ReflectionClass($object);
		$docBlock = $classReflection->getDocComment();
		$lines = explode("\n", $docBlock);
		$annotations = array();
		foreach ($lines as $line)
		{
			if (preg_match('~^(((\s*\*)|/\*\*)\s*@)(?<annotationName>[^\s]+)\s+(?<annotationValue>.*)~', $line, $matches))
			{
				$annotations[$matches['annotationName']][] = $matches['annotationValue'];
			}
		}
		return $annotations;
	}
931408
public static function getPayload(string $token, string $secret): array
    {
        $parser = self::parser($token, $secret);

        return $parser->validate()->parse()->getPayload();
    }