本文整理汇总了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);
}
示例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';
}
}
示例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());
});
}
示例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;
}
示例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;
}
示例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)));
}
}
示例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);
}