本文整理匯總了PHP中Mautic\CoreBundle\Model\FormModel類的典型用法代碼示例。如果您正苦於以下問題:PHP FormModel類的具體用法?PHP FormModel怎麽用?PHP FormModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FormModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getEntity
/**
* {@inheritdoc}
*
* @return Point|null
*/
public function getEntity($id = null)
{
if ($id === null) {
return new Point();
}
return parent::getEntity($id);
}
示例2: getEntity
/**
* Get a specific entity or generate a new one if id is empty.
*
* @param $id
*
* @return null|object
*/
public function getEntity($id = null)
{
if ($id === null) {
return new LeadNote();
}
return parent::getEntity($id);
}
示例3: getEntity
/**
* {@inheritdoc}
*
* @return null|Client|Consumer
*/
public function getEntity($id = null)
{
if ($id === null) {
return $this->apiMode == 'oauth2' ? new Client() : new Consumer();
}
return parent::getEntity($id);
}
示例4: getEntity
/**
* Get a specific entity or generate a new one if id is empty
*
* @param $id
*
* @return null|object
*/
public function getEntity($id = null)
{
if ($id === null) {
return new Event();
}
$entity = parent::getEntity($id);
return $entity;
}
示例5: togglePublishStatus
/**
* {@inheritdoc}
*
* @param object $entity
*
* @return bool Force browser refresh
*/
public function togglePublishStatus($entity)
{
parent::togglePublishStatus($entity);
//clear the cache
/** @var \Mautic\CoreBundle\Helper\CacheHelper $cacheHelper */
$cacheHelper = $this->factory->getHelper('cache');
$cacheHelper->clearCache();
return true;
}
示例6: saveEntity
public function saveEntity($entity, $unlock = true)
{
if (!$entity instanceof Opportunity) {
throw new \InvalidArgumentException('entity is not an instance of Opportunity');
}
if (!$entity->getOwnerUser()) {
$entity->setOwnerUser($this->factory->getUser(true));
}
if ($leadId = $this->factory->getRequest()->get('leadId', false)) {
$entity->setLead($this->factory->getModel('lead')->getEntity($leadId));
}
parent::saveEntity($entity);
}
示例7: getEntity
/**
* Get a specific entity or generate a new one if id is empty
*
* @param $id
* @return null|object
*/
public function getEntity($id = null)
{
if ($id === null) {
$entity = new Asset();
} else {
$entity = parent::getEntity($id);
}
return $entity;
}
示例8: getEntity
/**
* {@inheritdoc}
*/
public function getEntity($id = null)
{
if ($id === null) {
return new User();
}
$entity = parent::getEntity($id);
if ($entity) {
//add user's permissions
$entity->setActivePermissions($this->em->getRepository('MauticUserBundle:Permission')->getPermissionsByRole($entity->getRole()));
}
return $entity;
}
示例9: deleteEntities
/**
* Delete an array of entities
*
* @param array $ids
*
* @return array
*/
public function deleteEntities($ids)
{
$this->getRepository()->nullParents($ids);
return parent::deleteEntities($ids);
}
示例10: getEntity
/**
* Here just so PHPStorm calms down about type hinting.
*
* @param null $id
*
* @return null|DynamicContent
*/
public function getEntity($id = null)
{
return parent::getEntity($id);
}
示例11: getEntity
/**
* Get a specific entity or generate a new one if id is empty
*
* @param $id
*
* @return null|Email
*/
public function getEntity($id = null)
{
if ($id === null) {
$entity = new Email();
$entity->setSessionId('new_' . hash('sha1', uniqid(mt_rand())));
} else {
$entity = parent::getEntity($id);
if ($entity !== null) {
$entity->setSessionId($entity->getId());
}
}
return $entity;
}
示例12: deleteEntity
/**
* @param object $entity
*/
public function deleteEntity($entity)
{
// Delete custom avatar if one exists
$imageDir = $this->factory->getSystemPath('images', true);
$avatar = $imageDir . '/lead_avatars/avatar' . $entity->getId();
if (file_exists($avatar)) {
unlink($avatar);
}
parent::deleteEntity($entity);
}
示例13: deleteEntity
/**
* Delete an entity
*
* @param $entity
* @return null|object
*/
public function deleteEntity($entity)
{
$bundle = $entity->getBundle();
//if it doesn't have a dot, then assume the model will be $bundle.$bundle
$modelName = strpos($bundle, '.') === false ? $bundle . '.' . $bundle : $bundle;
$model = $this->factory->getModel($modelName);
$repo = $model->getRepository();
$tableAlias = $repo->getTableAlias();
$entities = $model->getEntities(array('filter' => array('force' => array(array('column' => $tableAlias . '.category', 'expr' => 'eq', 'value' => $entity->getId())))));
if (!empty($entities)) {
foreach ($entities as $e) {
$e->setCategory(null);
}
$model->saveEntities($entities, false);
}
parent::deleteEntity($entity);
}
示例14: saveEntity
/**
* Create/edit entity
*
* @param object $entity
* @param bool $unlock
*/
public function saveEntity($entity, $unlock = true)
{
// Set widget name from widget type if empty
if (!$entity->getName()) {
$entity->setName($this->translator->trans('mautic.widget.' . $entity->getType()));
}
parent::saveEntity($entity, $unlock);
}
示例15: deleteEntity
/**
* @param object $entity
*/
public function deleteEntity($entity)
{
// Null all the event parents for this campaign to avoid database constraints
$this->getEventRepository()->nullEventParents($entity->getId());
parent::deleteEntity($entity);
}