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


PHP Scalr::decamelize方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  *
  * @throws  \Scalr\Exception\AnalyticsException
  */
 public function __construct()
 {
     $this->timelineEvent = new TimelineEventEntity();
     $request = \Scalr::getContainer()->request;
     $this->user = $request instanceof Scalr_UI_Request ? $request->getUser() : null;
     $this->timelineEvent->userId = $this->user->id;
     $constName = 'Scalr\\Stats\\CostAnalytics\\Entity\\TimelineEventEntity::EVENT_TYPE_' . strtoupper(substr(\Scalr::decamelize(preg_replace('/^.+\\\\([\\w]+)$/', '\\1', get_class($this))), 0, -6));
     if (!defined($constName)) {
         throw new AnalyticsException(sprintf("Constant '%s' is not defined.", $constName));
     }
     $this->timelineEvent->eventType = constant($constName);
 }
开发者ID:rickb838,项目名称:scalr,代码行数:17,代码来源:AbstractEvent.php

示例2: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $basename = preg_replace('/^.+\\\\(\\w+)$/', '$1', get_class($this));
     $this->name = \Scalr::decamelize($basename);
     $this->pids = [];
     $this->toDisconnect = [];
     $this->setLogger(\Scalr::getContainer()->logger($this->name)->setLevel($this->config()->log_level));
     //It is possible to redefine default payload class for the task
     if (file_exists(__DIR__ . '/Payload/' . $basename . 'Payload.php')) {
         $this->payloadClass = __NAMESPACE__ . '\\Payload\\' . $basename . 'Payload';
     }
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:15,代码来源:AbstractTask.php

示例3: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $basename = preg_replace('/^.+\\\\(\\w+)$/', '$1', get_class($this));
     $this->name = \Scalr::decamelize($basename);
     $this->pids = [];
     $this->toDisconnect = [];
     $this->setLogger(\Scalr::getContainer()->logger($this->name)->setLevel($this->config()->log_level));
     //It is possible to redefine default payload class for the task
     if (file_exists(__DIR__ . '/Payload/' . $basename . 'Payload.php')) {
         $this->payloadClass = __NAMESPACE__ . '\\Payload\\' . $basename . 'Payload';
     }
     $container = \Scalr::getContainer();
     $container->release('auditlogger');
     $container->setShared('auditlogger', function ($cont) {
         return new AuditLogger(null, null, null, null, AuditLogger::REQUEST_TYPE_SYSTEM, $this->getName());
     });
 }
开发者ID:mheydt,项目名称:scalr,代码行数:20,代码来源:AbstractTask.php

示例4: listByFilter

 /**
  * Gets a list of servers by filter
  *
  * @param array $filter optional Filter value ['envId' => 'value']
  * @return array Returns array of DBServer objects
  */
 public static function listByFilter(array $filter = null)
 {
     $result = [];
     $db = \Scalr::getDb();
     $where = "WHERE 1=1";
     if (isset($filter)) {
         foreach ($filter as $name => $value) {
             $fieldName = \Scalr::decamelize($name);
             $where .= " AND " . $fieldName . "=" . $db->qstr($value);
         }
     }
     $servers = $db->GetAll("SELECT * FROM servers " . $where);
     foreach ($servers as $server) {
         $DBServer = new DBServer($server['server_id']);
         foreach (self::$FieldPropertyMap as $k => $v) {
             if (isset($server[$k])) {
                 $DBServer->{$v} = $server[$k];
             }
         }
         $result[] = $DBServer;
     }
     return $result;
 }
开发者ID:mheydt,项目名称:scalr,代码行数:29,代码来源:class.DBServer.php

示例5: save

 /**
  * Saves an entity to database
  *
  * @return \Scalr\Server\History
  * @throws Exception
  */
 public function save()
 {
     $stmt = array();
     $bind = array();
     $idKey = 'id';
     $idValue = array();
     $cols = array();
     foreach ($this->_getFields() as $field) {
         $cols[$field] = $this->{$field};
     }
     if (array_key_exists($idKey, $cols)) {
         if ($cols[$idKey]) {
             $idValue[] = $cols[$idKey];
         }
         unset($cols[$idKey]);
     }
     foreach ($cols as $field => $value) {
         $stmt[] = "`" . \Scalr::decamelize($field) . "` = ?";
         $bind[] = $value;
     }
     try {
         $stmt = (empty($idValue) ? "INSERT" : "UPDATE") . " `servers_history` SET " . join(", ", $stmt) . (!empty($idValue) ? " WHERE `" . \Scalr::decamelize($idKey) . "` = ?" : "");
         $this->db->Execute($stmt, array_merge($bind, $idValue));
         if (empty($idValue)) {
             $this->{$idKey} = $this->db->Insert_ID();
         }
     } catch (Exception $e) {
         throw new Exception(sprintf("Cannot save server history record. Error: %s", $e->getMessage()), $e->getCode());
     }
     return $this;
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:37,代码来源:History.php

示例6: load

 /**
  * Loads field or class annotation
  *
  * @param   \ReflectionProperty|\ReflectionClass  $refl Reflection property or class
  */
 public function load($refl)
 {
     if ($refl instanceof \ReflectionProperty || $refl instanceof \ReflectionClass) {
         $str = join('|', array_map('preg_quote', array_keys($this->mappingClasses)));
         $comment = $refl->getDocComment();
         $annotation = $refl instanceof \ReflectionProperty ? new Field() : new Entity();
         $annotation->name = $refl->name;
         if (preg_match_all('/^\\s+\\*\\s+@(' . $str . ')(.*)$/m', $comment, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $m) {
                 $mappingClass = 'Scalr\\Model\\Mapping\\' . $m[1];
                 $annotationProperty = lcfirst($m[1]);
                 $mapping = new $mappingClass();
                 if (!empty($m[2])) {
                     $definition = trim($m[2], "\r\t\n ()");
                     if ($definition) {
                         if (method_exists($mapping, '__invoke')) {
                             $mapping(trim($definition, "\"'"));
                         } else {
                             $str = '{' . preg_replace('/([\\w"]+)\\s*=/', '"$1":', $definition) . '}';
                             $type = json_decode($str, true);
                             if ($type) {
                                 foreach (get_class_vars($mappingClass) as $k => $defaultValue) {
                                     if (isset($type[$k])) {
                                         $mapping->{$k} = $type[$k];
                                     }
                                 }
                             } else {
                                 throw new ModelException(sprintf("Invalid annotation '%s' for %s of %s", $m[0], $refl->name, isset($refl->class) ? $refl->class : 'class'));
                             }
                         }
                     }
                 }
                 $annotation->{$annotationProperty} = $mapping;
             }
         }
         if ($refl instanceof \ReflectionProperty) {
             if (!$annotation->column instanceof Column) {
                 $annotation->column = new Column();
                 $annotation->column->type = 'string';
             }
             if (!$annotation->column->name) {
                 $annotation->column->name = \Scalr::decamelize($annotation->name);
             }
         }
         $refl->annotation = $annotation;
     } else {
         throw new \InvalidArgumentException(sprintf('Either ReflectionProperty or ReflectionClass is expected, "%s" passed.', is_object($refl) ? get_class($refl) : gettype($refl)));
     }
 }
开发者ID:rickb838,项目名称:scalr,代码行数:54,代码来源:MappingLoader.php

示例7: checkPermission

 /**
  * Checks if user has permissions to project in environment or account scope
  *
  * @param string $projectId     Identifier of the project
  * @param array $criteria       ['envId' => '', 'clientid' => '']
  * @return bool|mixed
  */
 public function checkPermission($projectId, array $criteria)
 {
     $and = '';
     foreach ($criteria as $name => $value) {
         $field = 'f.' . \Scalr::decamelize($name);
         $and .= " AND " . $field . "=" . $this->db->escape($value);
     }
     $projectEntity = new ProjectEntity();
     $projectId = $projectEntity->type('projectId')->toDb($projectId);
     $where = " WHERE p.project_id = UNHEX('" . $projectId . "') AND EXISTS (\n                SELECT * FROM farms f\n                LEFT JOIN farm_settings fs ON f.id = fs.farmid\n                WHERE fs.name = '" . Entity\FarmSetting::PROJECT_ID . "'\n                AND REPLACE(fs.value, '-', '') = HEX(p.project_id)\n                {$and})";
     $sql = "SELECT " . $projectEntity->fields('p') . "\n                FROM " . $projectEntity->table('p') . $where;
     return $this->db->GetOne($sql);
 }
开发者ID:mheydt,项目名称:scalr,代码行数:20,代码来源:Projects.php


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