Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function addRuletextLine($ruletextLine)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addRuletextLine', array($ruletextLine));
     return parent::addRuletextLine($ruletextLine);
 }
Exemplo n.º 2
0
 /**
  * @param array $ruleArray
  */
 protected function parseRules(array $ruleArray)
 {
     $rules = array();
     $currentRule = new Rule();
     foreach ($ruleArray as $ruleLine) {
         if ('' === $ruleLine) {
             continue;
         }
         $matches = array();
         $isMatch = preg_match('/^(?P<chapter>[0-9])(?P<major>[0-9]{2})?\\.(?P<minor>[0-9]+)?(?:(?P<paragraph>[a-z])|\\.)?\\s*/S', $ruleLine, $matches);
         if (!$isMatch) {
             $currentRule->addRuletextLine($ruleLine);
             continue;
         }
         $depth = 1;
         $id = rtrim(trim($matches[0]), '.');
         $subId = rtrim(trim(end($matches)), '.');
         $currentRule = new Rule();
         $currentRule->setId($id)->setSubId($subId)->setRuletext(substr($ruleLine, strlen($matches[0])));
         $this->objectManager->persist($currentRule);
         if (empty($matches['major'])) {
             $currentRule->setDepth($depth);
             $rules[$matches['chapter']] = $currentRule;
             continue;
         }
         ++$depth;
         $parentRule = $rules[$matches['chapter']];
         if (!empty($matches['minor'])) {
             $parentRule = $parentRule->getChildRule($matches['major']);
             ++$depth;
         }
         if (!empty($matches['paragraph'])) {
             $parentRule = $parentRule->getChildRule($matches['minor']);
             ++$depth;
         }
         $currentRule->setDepth($depth);
         $parentRule->addChildRule($currentRule);
     }
 }
Exemplo n.º 3
0
 /**
  * @param Rule $rule
  * @return Rule
  */
 public function addChildRule(Rule $rule)
 {
     if ($this !== $rule->getParentRule()) {
         $rule->setParentRule($this);
     }
     $this->childRules[$rule->getSubId()] = $rule;
     return $this;
 }