public function apply()
 {
     $formElementDefinition = new InsertFormElementDefinition();
     $property = false;
     if ($this->hasList(3)) {
         $property = true;
         $formElementDefinition->setWorkspaces($this->getList(2));
         $formElementDefinition->setLanguages($this->getList(3));
     } elseif ($this->hasList(2)) {
         $formElementDefinition->setWorkspaces($this->getList(1));
         $formElementDefinition->setLanguages($this->getList(2));
     } elseif ($this->hasList(1)) {
         $property = true;
     }
     if ($property) {
         if (!$this->hasParam(1)) {
             throw new CMDLParserException('Missing mandatory parameter property for annotation @insert.', CMDLParserException::CMDL_MISSING_MANDATORY_PARAM);
         }
         $formElementDefinition->setPropertyName($this->getParam(1));
         $formElementDefinition->setInsertConditions($this->getList(1));
     } else {
         if (!$this->hasParam(1)) {
             throw new CMDLParserException('Missing mandatory parameter clipping name for annotation @insert.', CMDLParserException::CMDL_MISSING_MANDATORY_PARAM);
         }
         $formElementDefinition->setClippingName($this->getParam(1));
     }
     $this->currentFormElementDefinitionCollection->addFormElementDefinition($formElementDefinition);
     return $this->dataTypeDefinition;
 }
 /**
  * @param DataTypeDefinition $dataTypeDefinition
  * @param array              $values
  *
  * @return mixed
  */
 public function getClippingDefinition($dataTypeDefinition, $values = array(), $attributes = array())
 {
     if ($this->definition->getPropertyName()) {
         $value = null;
         if (strpos($this->definition->getPropertyName(), '.') !== false) {
             $attribute = array_pop(explode('.', $this->definition->getPropertyName()));
             if (array_key_exists($attribute, $attributes)) {
                 $value = $attributes[$attribute];
             }
         } else {
             if (array_key_exists($this->definition->getPropertyName(), $values)) {
                 $value = $values[$this->definition->getPropertyName()];
             }
         }
         $clippingName = $this->definition->getClippingName($value);
     } else {
         $clippingName = $this->definition->getClippingName();
     }
     if ($dataTypeDefinition->hasClippingDefinition($clippingName)) {
         $clippingDefinition = $dataTypeDefinition->getClippingDefinition($clippingName);
         if ($this->definition->hasWorkspacesRestriction()) {
             if (!in_array($this->context->getCurrentWorkspace(), $this->definition->getWorkspaces())) {
                 return false;
             }
         }
         if ($this->definition->hasLanguagesRestriction()) {
             if (!in_array($this->context->getCurrentLanguage(), $this->definition->getLanguages())) {
                 return false;
             }
         }
         return $clippingDefinition;
     } else {
         return false;
     }
 }