Sulu\Component\Util\SuluNodeHelper::getLanguagesForNode PHP Method

getLanguagesForNode() public method

Return the languages that are currently registered on the given PHPCR node.
public getLanguagesForNode ( PHPCR\NodeInterface $node ) : array
$node PHPCR\NodeInterface
return array
    public function getLanguagesForNode(NodeInterface $node)
    {
        $languages = [];
        foreach ($node->getProperties() as $property) {
            /* @var PropertyInterface $property */
            preg_match('/^' . $this->languageNamespace . ':([a-zA-Z_]*?)-changer/', $property->getName(), $matches);
            if ($matches) {
                $languages[$matches[1]] = $matches[1];
            }
        }
        return array_values($languages);
    }

Usage Example

コード例 #1
0
ファイル: ContentNodeDeleteEvent.php プロジェクト: sulu/sulu
 /**
  * Return all structures (i.e. for for each language).
  *
  * @return Sulu\Component\Content\MetadataInterface[]
  */
 public function getStructures()
 {
     $structures = [];
     foreach ($this->nodeHelper->getLanguagesForNode($this->node) as $locale) {
         $structures[] = $this->getStructure($locale);
     }
     return $structures;
 }