当前位置: 首页>>代码示例>>PHP>>正文


PHP MauticFactory::getDatabase方法代码示例

本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getDatabase方法的具体用法?PHP MauticFactory::getDatabase怎么用?PHP MauticFactory::getDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mautic\CoreBundle\Factory\MauticFactory的用法示例。


在下文中一共展示了MauticFactory::getDatabase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTokens

 /**
  * @param string              $tokenRegex     Token regex without wrapping regex escape characters.  Use (value) or (.*?) where the ID of the
  *                                            entity should go. i.e. {pagelink=(value)}
  * @param string              $filter         String to filter results by
  * @param string              $labelColumn    The column that houses the label
  * @param string              $valueColumn    The column that houses the value
  * @param CompositeExpression $expr           Use $factory->getDatabase()->getExpressionBuilder()->andX()
  *
  * @return array|void
  */
 public function getTokens($tokenRegex, $filter = '', $labelColumn = 'name', $valueColumn = 'id', CompositeExpression $expr = null)
 {
     //set some permissions
     $permissions = $this->factory->getSecurity()->isGranted($this->permissionSet, "RETURN_ARRAY");
     if (in_array(false, $permissions)) {
         return;
     }
     $repo = $this->factory->getModel($this->modelName)->getRepository();
     $prefix = $repo->getTableAlias();
     if (!empty($prefix)) {
         $prefix .= '.';
     }
     $exprBuilder = $this->factory->getDatabase()->getExpressionBuilder();
     if ($expr == null) {
         $expr = $exprBuilder->andX();
     }
     if (isset($permissions[$this->viewPermissionBase . ':viewother']) && !$permissions[$this->viewPermissionBase . ':viewother']) {
         $expr->add($exprBuilder->eq($prefix . 'createdBy', $this->factory->getUser()->getId()));
     }
     if (!empty($filter)) {
         $expr->add($exprBuilder->like('LOWER(' . $labelColumn . ')', ':label'));
         $parameters = array('label' => strtolower($filter) . '%');
     } else {
         $parameters = array();
     }
     $items = $repo->getSimpleList($expr, $parameters, $labelColumn, $valueColumn);
     $tokens = array();
     foreach ($items as $item) {
         $token = str_replace(array('(value)', '(.*?)'), $item['value'], $tokenRegex);
         $tokens[$token] = $item['label'];
     }
     return $tokens;
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:43,代码来源:BuilderTokenHelper.php

示例2: onPluginInstall

 /**
  * @param Plugin $plugin
  * @param MauticFactory $factory
  * @param array $metadata
  * @param null $installedSchema
  */
 public static function onPluginInstall(Plugin $plugin, MauticFactory $factory, $metadata = null, $installedSchema = null)
 {
     if (is_array($metadata)) {
         foreach ($metadata as $key => $entity) {
             /** @var \Doctrine\ORM\Mapping\ClassMetadata $entity */
             if ($factory->getDatabase()->getSchemaManager()->tablesExist($entity->getTableName())) {
                 unset($metadata[$key]);
             }
         }
         self::installPluginSchema($metadata, $factory);
     }
 }
开发者ID:redmantech,项目名称:Mautic_CRM,代码行数:18,代码来源:CustomCrmBundle.php

示例3: findPropertyName

 /**
  * Finds/creates the local name for constraints and indexes.
  *
  * @param $table
  * @param $type
  * @param $suffix
  *
  * @return string
  */
 protected function findPropertyName($table, $type, $suffix)
 {
     static $schemaManager;
     static $tables = [];
     if (empty($schemaManager)) {
         $schemaManager = $this->factory->getDatabase()->getSchemaManager();
     }
     // Prepend prefix
     $table = $this->prefix . $table;
     if (!array_key_exists($table, $tables)) {
         $tables[$table] = [];
     }
     $type = strtolower($type);
     $suffix = strtolower(substr($suffix, -4));
     switch ($type) {
         case 'fk':
             if (!array_key_exists('fk', $tables[$table])) {
                 $keys = $schemaManager->listTableForeignKeys($table);
                 /** @var \Doctrine\DBAL\Schema\ForeignKeyConstraint $k */
                 foreach ($keys as $k) {
                     $name = strtolower($k->getName());
                     $key = substr($name, -4);
                     $tables[$table]['fk'][$key] = $name;
                 }
             }
             $localName = $tables[$table]['fk'][$suffix];
             break;
         case 'idx':
         case 'uniq':
             if (!array_key_exists('idx', $tables[$table])) {
                 $tables[$table]['idx'] = ['idx' => [], 'uniq' => []];
                 $indexes = $schemaManager->listTableIndexes($table);
                 /** @var \Doctrine\DBAL\Schema\Index $i */
                 foreach ($indexes as $i) {
                     $name = strtolower($i->getName());
                     $isIdx = stripos($name, 'idx');
                     $isUniq = stripos($name, 'uniq');
                     if ($isIdx !== false || $isUniq !== false) {
                         $key = substr($name, -4);
                         $keyType = $isIdx !== false ? 'idx' : 'uniq';
                         $tables[$table]['idx'][$keyType][$key] = $name;
                     }
                 }
             }
             $localName = $tables[$table]['idx'][$type][$suffix];
             break;
     }
     $localName = strtoupper($localName);
     return $localName;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:59,代码来源:AbstractMauticMigration.php

示例4: addTaskAction

 public static function addTaskAction(MauticFactory $factory, $lead, $event)
 {
     $sql = 'INSERT INTO tasks (due_date, name, lead_id, assign_user_id, is_completed, date_added) VALUES (?, ?, ?, ?, ?, ?)';
     $stmt = $factory->getDatabase()->prepare($sql);
     $dueDate = self::generateDueDate($event);
     $stmt->bindValue(1, $dueDate->format('Y-m-d H:i:s'));
     $stmt->bindValue(2, $event['properties']['name']);
     $stmt->bindValue(3, $lead->getId());
     $stmt->bindValue(4, $event['properties']['assignUser']);
     $stmt->bindValue(5, 0);
     $dateTime = new \DateTime('now');
     $stmt->bindValue(6, $dateTime->format('Y-m-d H:i:s'));
     $stmt->execute();
     return true;
 }
开发者ID:redmantech,项目名称:Mautic_CRM,代码行数:15,代码来源:CampaignEventHelper.php

示例5: dropPluginSchema

 /**
  * Drops plugin's tables based on Doctrine metadata.
  *
  * @param array         $metadata
  * @param MauticFactory $factory
  *
  * @throws \Doctrine\DBAL\ConnectionException
  * @throws \Exception
  */
 public static function dropPluginSchema(array $metadata, MauticFactory $factory)
 {
     $db = $factory->getDatabase();
     $schemaTool = new SchemaTool($factory->getEntityManager());
     $dropQueries = $schemaTool->getDropSchemaSQL($metadata);
     $db->beginTransaction();
     try {
         foreach ($dropQueries as $q) {
             $db->query($q);
         }
         $db->commit();
     } catch (\Exception $e) {
         $db->rollback();
         throw $e;
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:25,代码来源:PluginBundleBase.php

示例6: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->factory = $factory;
     $this->db = $factory->getDatabase();
     $this->logger = $this->factory->getLogger();
 }
开发者ID:Yame-,项目名称:mautic,代码行数:9,代码来源:MessageHelper.php


注:本文中的Mautic\CoreBundle\Factory\MauticFactory::getDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。