@param Driver         $driver
@param ModelInterface $model

@return bool
161087
public function remove(Driver $driver, ModelInterface $model)
    {
        $this->managerFactory->setModelClass(get_class($model));
        $manager = $this->managerFactory->getManager($driver);
        $event = new FilterModelEvent();
        $event->setModel($model);
        $event->setManager($manager);
        $this->eventSubscriber->subscribe(Constants::PRE_DELETE, $event);

        /** @var JsonResponse $response */
        if ($response = $event->getResponse() instanceof JsonResponse) {
            $content = json_decode($response->getContent(), true);
            $this->errorMessage = isset($content['message']) ? $content['message'] : 'message.delete_failed';

            return false;
        }

        try {
            $manager->remove($model);
        } catch (\Exception $exception) {
            $this->errorMessage = 'message.delete_failed';

            return false;
        }

        return true;
    }
782850
public function remove(ModelInterface $model)
    {
        /** @var DeleteActionHandler $viewHandler */
        $viewHandler = $this->actionHandlers[DeleteActionHandler::class];
        $viewHandler->setView($this->view);
        $viewHandler->setRequest($this->request);
        $viewHandler->setData($model);

        $view = $viewHandler->getView($this->driver);

        return new JsonResponse(array(
            'status' => !$view->getParam('errors'),
            'message' => $view->getParam('message'),
        ));
    }
1180333
public function setModel(ModelInterface $model = null): ModelReferenceInterface
    {
        $this->resolveModel();

        $this->model = $model;
        $this->id = null !== $model ? $model->getId() : null;

        return $this;
    }
732785
public function bind(ViewModelInterface $model)
	{
		$this->scoped['@file'] = $model->getResource();
		$this->scoped['@model'] = $this->model = $model;
		$this->scoped['@context'] = $this;
		
		$this->renderer->triggerContextBound($this);
	}
819085
private function createDriverNode(ResourceInterface $resource)
    {
        $driverNode = $this->createNode('driver')->addDefaultsIfNotSet();
        $driverNode->children()
            ->append($this->createNode('name', 'scalar', $resource->getDriver()))
            ->append($this->createNode('manager', 'scalar', $resource->getDriverManager()))
            ->append($this->createDriverMappingNode($resource));

        return $driverNode;
    }
597812
private function isOwner(AccountInterface $account, Model $resource)
    {
        /** @var Model $resource */
        if ($this->isAuthenticated($account) === true) {
            $userId  = $account->getAuthIdentifier();
            $ownerId = $resource->{Model::FIELD_ID_USER};
            $isOwner = $userId === $ownerId;

            return $isOwner;
        }

        return false;
    }
887057
public function create(ModelInterface $model)
    {
        $user = $this->container->make(UserSingularity::class);

        $user
            ->setModel($model)
            ->boot();

        return $user;
    }
175903
public function identifyEntity(ModelInterface $model, &$entity, $identifier)
    {
        $primaryKeys = $model->primaryFields();
        if (count($primaryKeys) !== 1) {
            return;
        }

        $field = reset($primaryKeys)->name();

        $this->setPropertyValue($entity, $field, $identifier);
    }
941272
public function addDriver(DriverInterface $driver)
    {
        $driver->setConnector($this);
        $this->driverList[$driver->getDriverId()] = $driver;

        return $this;
    }
1325249
protected function storeVersion(ModelInterface $model)
    {
        $modelId                 = $model->getId();
        $environment             = $this->getEnvironment();
        $definition              = $this->getDataDefinition();
        $dataProvider            = $environment->getDataProvider($model->getProviderName());
        $dataProviderDefinition  = $definition->getDataProviderDefinition();
        $dataProviderInformation = $dataProviderDefinition->getInformation($model->getProviderName());

        if (!$dataProviderInformation->isVersioningEnabled()) {
            return;
        }

        // Compare version and current record.
        $currentVersion = $dataProvider->getActiveVersion($modelId);
        if (!$currentVersion
            || !$dataProvider->sameModels($model, $dataProvider->getVersion($modelId, $currentVersion))
        ) {
            $user = BackendUser::getInstance();

            $dataProvider->saveVersion($model, $user->username);
        }
    }
665098
private function hasProperty(ModelInterface $model, string $name): bool
    {
        $hasRelationship = property_exists($model, $name);

        return $hasRelationship;
    }
798740
private function isRootModel(ModelInterface $model)
    {
        return (null !== $this->rootCondition) && $this->rootCondition->matches($model);
    }
88844
public function getValue(ModelInterface $model)
    {
        $value = parent::getValue($model);

        if (!$value) {
            return;
        }

        return $value->getHash();
    }
1039290
public function persist(ModelInterface $model): RepositoryInterface
    {
        $id = $model->getId();
        $row = $model->toPersistence();

        $this->connection->beginTransaction();

        $alreadyExists = (bool) $this->find($id);

        $stack = new RelatedModelManipulationStack();

        foreach ($row as $field => $value) {
            if ($value instanceof ModelCollectionInterface) {
                $stack->addToRemoveModels($value->getInitialModels());
                $stack->addToPersistModels($value->getModels());
                unset($row[$field]);
            } elseif ($value instanceof ModelReferenceInterface) {
                $row[$field.'Id'] = $this->persistModelReference($value, $stack);

                unset($row[$field]);
            }
        }

        if (!$alreadyExists) {
            $this->insert($id, $row);
        } else {
            $this->update($id, $row);
        }

        $this->removeRelatedModels($stack->getToRemoveModels());
        $this->persistRelatedModels($stack->getToPersistModels());

        $this->storageCache->set($id, $row);

        $this->connection->commit();

        return $this;
    }
304495
public function equals($id)
    {
        if ($id instanceof ModelIdInterface) {

            return ($id->getValue() === $this->value);
        } elseif (is_a($id, $this->getModelClass(), true)) {

            $model = $id;

            if (!$model instanceof ModelInterface) {
                throw new \RuntimeException(sprintf('Model class %s must implement ModelInterface', get_class($model)));
            }

            return ($this->equals($model->id()->getValue()));
        }

        return ($this->getValue() === (string)$id);
    }
343126
public function addDriver(DriverInterface $driver, $namespace) {
        if (!isset($this->drivers[$namespace]))
            $this->drivers[$namespace] = array();
        $this->drivers[$namespace][] = $driver;
        return $this;
    }
239115
public function setExternalDataHandler (DataHandlerDriverInterface $driver) : bool
    {
        if (!$this->_Votes->isUsingHandler()) :
            $this->_Votes->importHandler($driver);
            return true;
        else :
            throw new CondorcetException(24);
        endif;
    }