/** * @param string $title * @param int $nodeId * @param string $slug * @param string $lang * @param int $refId * @param string $refName * @param string $internalName */ public function __construct($title, $nodeId, $slug, $lang, $refId, $refName, $internalName) { parent::__construct($title, $nodeId, $slug); $this->lang = $lang; $this->refId = $refId; $this->refName = $refName; $this->internalName = $internalName; }
/** * @param Category $category * @param string $lang * * @return Branch|null */ public function getBranchByCategory(Category $category, $lang = null) { $this->initNodeVersions(); $lang = $lang ?: $this->currentLocale->getCurrentLocale(); $matches = function (Branch $branch) use($category, $lang) { return $category->getNodeId() === $branch->getNodeId() && $lang === $branch->getLang(); }; return array_reduce($this->branches, function (Branch $result = null, Branch $branch) use($matches) { return $matches($branch) ? $branch : $result; }); }