public function reverseTransform($value)
 {
     if (!$value) {
         return;
     }
     $lead = $this->model->getEntity($value);
     if (null === $value) {
         throw new TransformationFailedException(sprintf('An Lead with id "%s" does not exist!', $value));
     }
     return $lead;
 }
Example #2
0
 /**
  * Checks access to an entity
  *
  * @param object                               $entity
  * @param int                                  $objectId
  * @param array                                $permissions
  * @param \Mautic\CoreBundle\Model\CommonModel $model
  * @param string                               $modelName
  *
  * @return HttpFoundation\JsonResponse|HttpFoundation\RedirectResponse|void
  */
 private function checkEntityAccess($postActionVars, $entity, $objectId, array $permissions, $model, $modelName)
 {
     if ($entity === null) {
         return $this->postActionRedirect(array_merge($postActionVars, ['flashes' => [['type' => 'error', 'msg' => 'mautic.report.report.error.notfound', 'msgVars' => ['%id%' => $objectId]]]]));
     } elseif (!$this->container->get('mautic.security')->hasEntityAccess($permissions[0], $permissions[1], $entity->getCreatedBy())) {
         return $this->accessDenied();
     } elseif ($model->isLocked($entity)) {
         //deny access if the entity is locked
         return $this->isLocked($postActionVars, $entity, $modelName);
     }
     return true;
 }
Example #3
0
 /**
  * Creates the form instance
  *
  * @param $entity
  *
  * @return mixed
  */
 protected function createEntityForm($entity)
 {
     return $this->model->createForm($entity, $this->get('form.factory'));
 }