public function validate($value, Constraint $constraint)
 {
     $value = StringHandler::classify($value);
     /*
      * If value is already the node name
      * do nothing.
      */
     if (null !== $constraint->currentValue && $value == $constraint->currentValue) {
         return;
     }
     if (null !== $constraint->entityManager) {
         if (true === $this->nameExists($value, $constraint->entityManager)) {
             $this->context->addViolation($constraint->message);
         }
     } else {
         $this->context->addViolation('UniqueNodeTypeNameValidator constraint requires a valid EntityManager');
     }
 }
 /**
  * Get controller class path for a given node.
  *
  * @param Node $node
  *
  * @return string
  */
 public function getControllerForNode(Node $node)
 {
     $currentClass = get_class($this);
     $refl = new \ReflectionClass($currentClass);
     $namespace = $refl->getNamespaceName() . '\\Controllers';
     /*
      * Determine if we look for a node-type named controller or
      * a node-named controller.
      */
     if (in_array($node->getNodeName(), static::$specificNodesControllers)) {
         return $namespace . '\\' . StringHandler::classify($node->getNodeName()) . 'Controller';
     } else {
         return $namespace . '\\' . StringHandler::classify($node->getNodeType()->getName()) . 'Controller';
     }
 }
Example #3
0
 /**
  * @param string $name
  *
  * @return $this
  */
 public function setName($name)
 {
     $this->name = StringHandler::classify($name);
     return $this;
 }