• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Scalr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: xRequestResultAction

 public function xRequestResultAction()
 {
     $this->request->defineParams(array('requests' => array('type' => 'json'), 'decision'));
     if (!in_array($this->getParam('decision'), array(FarmLease::STATUS_APPROVE, FarmLease::STATUS_DECLINE))) {
         throw new Scalr_Exception_Core('Wrong status');
     }
     foreach ($this->getParam('requests') as $id) {
         $req = $this->db->GetRow('SELECT * FROM farm_lease_requests WHERE id = ? LIMIT 1', array($id));
         if ($req) {
             $dbFarm = DBFarm::LoadByID($req['farm_id']);
             $this->user->getPermissions()->validate($dbFarm);
             $this->db->Execute('UPDATE farm_lease_requests SET status = ?, answer_comment = ?, answer_user_id = ? WHERE id = ?', array($this->getParam('decision'), $this->getParam('comment'), $this->user->getId(), $id));
             try {
                 $mailer = Scalr::getContainer()->mailer;
                 if ($dbFarm->ownerId) {
                     $user = Entity\Account\User::findPk($dbFarm->ownerId);
                     if (\Scalr::config('scalr.auth_mode') == 'ldap') {
                         $email = $user->getSetting(Entity\Account\User\UserSetting::NAME_LDAP_EMAIL);
                         if (!$email) {
                             $email = $user->email;
                         }
                     } else {
                         $email = $user->email;
                     }
                     $mailer->addTo($email);
                 } else {
                     $mailer = null;
                 }
             } catch (Exception $e) {
                 $mailer = null;
             }
             if ($this->getParam('decision') == FarmLease::STATUS_APPROVE) {
                 if ($req['request_days'] > 0) {
                     $dt = $dbFarm->GetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE);
                     $dt = new DateTime($dt);
                     $dt->add(new DateInterval('P' . $req['request_days'] . 'D'));
                     $dbFarm->SetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE, $dt->format('Y-m-d H:i:s'));
                     $dbFarm->SetSetting(Entity\FarmSetting::LEASE_NOTIFICATION_SEND, null);
                     if ($mailer) {
                         $mailer->sendTemplate(SCALR_TEMPLATES_PATH . '/emails/farm_lease_non_standard_approve.eml', array('{{farm_name}}' => $dbFarm->Name, '{{user_name}}' => $this->user->getEmail(), '{{comment}}' => $this->getParam('comment'), '{{date}}' => $dt->format('M j, Y'), '{{envName}}' => $dbFarm->GetEnvironmentObject()->name, '{{envId}}' => $dbFarm->GetEnvironmentObject()->id));
                     }
                 } else {
                     $dbFarm->SetSetting(Entity\FarmSetting::LEASE_STATUS, '');
                     $dbFarm->SetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE, '');
                     $dbFarm->SetSetting(Entity\FarmSetting::LEASE_NOTIFICATION_SEND, '');
                     if ($mailer) {
                         $mailer->sendTemplate(SCALR_TEMPLATES_PATH . '/emails/farm_lease_non_standard_forever.eml', array('{{farm_name}}' => $dbFarm->Name, '{{user_name}}' => $this->user->getEmail(), '{{comment}}' => $this->getParam('comment'), '{{envName}}' => $dbFarm->GetEnvironmentObject()->name, '{{envId}}' => $dbFarm->GetEnvironmentObject()->id));
                     }
                 }
             } else {
                 $dt = new DateTime($dbFarm->GetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE));
                 SettingEntity::increase(SettingEntity::LEASE_DECLINED_REQUEST);
                 if ($mailer) {
                     $mailer->sendTemplate(SCALR_TEMPLATES_PATH . '/emails/farm_lease_non_standard_decline.eml', array('{{farm_name}}' => $dbFarm->Name, '{{user_name}}' => $this->user->getEmail(), '{{date}}' => $dt->format('M j, Y'), '{{comment}}' => $this->getParam('comment'), '{{envName}}' => $dbFarm->GetEnvironmentObject()->name, '{{envId}}' => $dbFarm->GetEnvironmentObject()->id));
                 }
             }
         }
     }
     $this->response->success();
 }
开发者ID:scalr,项目名称:scalr,代码行数:60,代码来源:Lease.php


示例2: getCrypto

 /**
  * @return CryptoTool
  */
 protected function getCrypto()
 {
     if (!$this->crypto) {
         $this->crypto = \Scalr::getContainer()->crypto;
     }
     return $this->crypto;
 }
开发者ID:scalr,项目名称:scalr,代码行数:10,代码来源:Model.php


示例3: __construct

 public function __construct(Scalr_Net_Dns_Bind_Transports_Ssh2_AuthInfo $authInfo, $host, $port, $rndcPath, $zonesPath)
 {
     $this->ssh2Client = new Scalr_Net_Ssh2_Client();
     $this->logger = \Scalr::getContainer()->logger(__CLASS__);
     $this->rndcPath = $rndcPath;
     $this->zonesPath = $zonesPath;
     $this->host = $host;
     switch ($authInfo->getType()) {
         case Scalr_Net_Dns_Bind_Transports_Ssh2_AuthInfo::TYPE_PASSWORD:
             $this->ssh2Client->addPassword($authInfo->login, $authInfo->password);
             break;
         case Scalr_Net_Dns_Bind_Transports_Ssh2_AuthInfo::TYPE_PUBKEY:
             $this->ssh2Client->addPubkey($authInfo->login, $authInfo->pubKeyPath, $authInfo->privKeyPath, $authInfo->keyPassword);
             break;
     }
     try {
         $this->ssh2Client->connect($host, $port);
     } catch (Scalr_Net_Ssh2_Exception $e) {
         throw new Exception("Unable to initialize SSH2 Transport: {$e->getMessage()}");
     }
     // COunt initial number of zones
     $this->zonesCount = $this->rndcStatus();
     if (!$this->zonesCount) {
         throw new Exception(sprintf(_("Cannot fetch RNDC status on %s"), $host));
     }
 }
开发者ID:mheydt,项目名称:scalr,代码行数:26,代码来源:Ssh2.php


示例4: setupScalrAgent

 public static function setupScalrAgent(\DBServer $dbServer)
 {
     $baseurl = \Scalr::config('scalr.endpoint.scheme') . "://" . \Scalr::config('scalr.endpoint.host');
     $env = $dbServer->GetEnvironmentObject();
     $azure = $env->azure();
     $branch = $dbServer->getScalarizrRepository()['repository'];
     $develRepos = \Scalr::getContainer()->config->get('scalr.scalarizr_update.devel_repos');
     $scmBranch = $dbServer->GetFarmRoleObject()->GetSetting('user-data.scm_branch');
     if ($scmBranch != '' && $develRepos) {
         $branch = $dbServer->GetFarmRoleObject()->GetSetting('base.devel_repository');
         $scmBranch = "{$scmBranch}/";
     } else {
         $scmBranch = '';
     }
     if ($dbServer->osType == 'linux') {
         $extensionProperties = new ResourceExtensionProperties('Microsoft.OSTCExtensions', 'CustomScriptForLinux', '1.2');
         $extensionProperties->setSettings(['commandToExecute' => "bash -c 'curl -k -L \"{$baseurl}/public/linux/{$branch}/azure/{$scmBranch}install_scalarizr.sh\" | bash && service scalr-upd-client start'"]);
     } else {
         $extensionProperties = new ResourceExtensionProperties('Microsoft.Compute', 'CustomScriptExtension', '1.4');
         $extensionProperties->setSettings(["commandToExecute" => "powershell -NoProfile -ExecutionPolicy Bypass -Command \"iex ((new-object net.webclient).DownloadString('{$baseurl}/public/windows/{$branch}/{$scmBranch}install_scalarizr.ps1')); start-service ScalrUpdClient\""]);
     }
     $createExtension = new CreateResourceExtension('scalarizr', $dbServer->cloudLocation, $extensionProperties);
     try {
         $response = $azure->compute->resourceExtension->create($env->keychain(SERVER_PLATFORMS::AZURE)->properties[Entity\CloudCredentialsProperty::AZURE_SUBSCRIPTION_ID], $dbServer->GetProperty(\AZURE_SERVER_PROPERTIES::RESOURCE_GROUP), $dbServer->GetProperty(\AZURE_SERVER_PROPERTIES::SERVER_NAME), $createExtension);
         \Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->info(new \FarmLogMessage($dbServer, sprintf(_("Created azure resource extension to install and launch scalr agent"))));
         $dbServer->SetProperty(\AZURE_SERVER_PROPERTIES::SZR_EXTENSION_DEPLOYED, 1);
     } catch (\Exception $e) {
         \Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->fatal(new \FarmLogMessage($dbServer, sprintf(_("Unable to create azure resource extension to install and launch scalr agent: %s"), $e->getMessage())));
     }
 }
开发者ID:scalr,项目名称:scalr,代码行数:30,代码来源:AzureHelper.php


示例5: tearDownAfterClass

 /**
  * {@inheritdoc}
  * @see Scalr\Tests\TestCase::tearDownAfterClass()
  */
 public static function tearDownAfterClass()
 {
     foreach (static::$testData as $rec) {
         if ($rec['class'] === Farm::class) {
             $entry = $rec['pk'];
             $farm = Farm::findPk(...$entry);
             /* @var $farm Farm */
             if (!empty($farm)) {
                 try {
                     \Scalr::FireEvent($farm->id, new FarmTerminatedEvent(false, false, false, false, true, static::$user->id));
                     foreach ($farm->servers as $server) {
                         try {
                             $dbServer = Server::findPk($server->serverId);
                             /* @var $dbServer Server */
                             $dbServer->terminate(Server::TERMINATE_REASON_FARM_TERMINATED, true, static::$user);
                         } catch (Exception $e) {
                             \Scalr::logException($e);
                         }
                         $server->delete();
                     }
                 } catch (Exception $e) {
                     \Scalr::logException($e);
                 }
             }
         }
     }
     parent::tearDownAfterClass();
 }
开发者ID:scalr,项目名称:scalr,代码行数:32,代码来源:ServersTest.php


示例6: startChild

 function startChild()
 {
     // Reopen DB connection in child
     $this->db = Core::GetDBInstance(null, true);
     // Reconfigure observers;
     Scalr::ReconfigureObservers();
 }
开发者ID:rakesh-mohanta,项目名称:scalr,代码行数:7,代码来源:DbMsrMaintenance.php


示例7: __construct

 function __construct()
 {
     $this->cryptoTool = \Scalr::getContainer()->srzcrypto;
     $this->serializer = new Scalr_Messaging_XmlSerializer();
     $this->jsonSerializer = new Scalr_Messaging_JsonSerializer();
     $this->logger = \Scalr::getContainer()->logger(__CLASS__);
 }
开发者ID:mheydt,项目名称:scalr,代码行数:7,代码来源:Service.php


示例8: __construct

 function __construct($nodeName, $jobConfig)
 {
     parent::__construct($nodeName, $jobConfig);
     $this->logger = \Scalr::getContainer()->logger(__CLASS__);
     if (!key_exists("datacenter", $jobConfig)) {
         throw new Scalr_System_Cronjob_Exception("Configuration array must have a key for 'datacenter'");
     }
     $dcConfig = $jobConfig["datacenter"];
     if (!$dcConfig["centers"]) {
         throw new Scalr_System_Cronjob_Exception("No datacenters defined in configuration");
     }
     if (!$dcConfig["leader"]) {
         throw new Scalr_System_Cronjob_Exception("Configuration array must have a key for 'datacenter'.'leader' " . "that names the leader datacenter");
     }
     $centers = array_map("trim", explode(",", $dcConfig["centers"]));
     $nodeCenterMap = array();
     foreach ($centers as $center) {
         $nodes = array_map("trim", explode(",", $dcConfig[$center]));
         foreach ($nodes as $node) {
             $nodeCenterMap[$node] = $center;
         }
     }
     $this->dataCenter = key_exists($this->nodeName, $nodeCenterMap) ? $nodeCenterMap[$this->nodeName] : $dcConfig["default"];
     $this->leaderDataCenter = $dcConfig["leader"];
 }
开发者ID:mheydt,项目名称:scalr,代码行数:25,代码来源:DataCenterElector.php


示例9: run1

 protected function run1($stage)
 {
     $this->console->out(sprintf("Reencrypting %s database from %s/%s to %s/%s!", \Scalr::getContainer()->config->get('scalr.connections.mysql.name'), $this->source->getCryptoAlgo(), $this->source->getCipherMode(), $this->target->getCryptoAlgo(), $this->target->getCipherMode()));
     set_error_handler(function ($code, $message, $file, $line, $context) {
         \Scalr::errorHandler($code, $message, $file, $line, $context);
         if ($code == E_STRICT) {
             throw new Exception($message);
         }
     }, E_USER_ERROR | E_STRICT | E_RECOVERABLE_ERROR | E_ERROR);
     try {
         $this->db->Execute('START TRANSACTION;');
         $this->recrypt('ssh_keys', ['private_key', 'public_key']);
         $this->recrypt('services_ssl_certs', ['ssl_pkey', 'ssl_pkey_password']);
         $this->recrypt('account_user_settings', ['value'], "WHERE `name` = 'security.2fa.ggl.key'", ['user_id', 'name']);
         $this->recrypt('services_chef_servers', ['auth_key', 'v_auth_key']);
         $this->recrypt('variables', ['value'], '', ['name'], $this->globals);
         $this->recrypt('account_variables', ['value'], '', ['name', 'account_id'], $this->globals);
         $this->recrypt('client_environment_variables', ['value'], '', ['name', 'env_id'], $this->globals);
         $this->recrypt('role_variables', ['value'], '', ['name', 'role_id'], $this->globals);
         $this->recrypt('farm_variables', ['value'], '', ['name', 'farm_id'], $this->globals);
         $this->recrypt('farm_role_variables', ['value'], '', ['name', 'farm_role_id'], $this->globals);
         $this->recrypt('server_variables', ['value'], '', ['name', 'server_id'], $this->globals);
         $reflection = new ReflectionClass('Scalr_Environment');
         $method = $reflection->getMethod('getEncryptedVariables');
         $method->setAccessible(true);
         $this->recrypt('client_environment_properties', ['value'], "WHERE `name` IN ('" . implode("','", array_keys($method->invoke(null))) . "')");
         $this->db->Execute("COMMIT;");
     } catch (\Exception $e) {
         $this->rollback($e->getCode(), $e->getMessage());
         restore_error_handler();
         throw $e;
     }
     restore_error_handler();
 }
开发者ID:scalr,项目名称:scalr,代码行数:34,代码来源:Update20150116130622.php


示例10: __call

 public function __call($method, $args)
 {
     // If observer enabled
     if (!$this->Config || $this->Config->GetFieldByName("IsEnabled")->Value == 0) {
         return;
     }
     $enabled = $this->Config->GetFieldByName("{$method}Notify");
     if (!$enabled || $enabled->Value == 0) {
         return;
     }
     $DB = \Scalr::getDb();
     // Event name
     $name = substr($method, 2);
     // Event message
     $message = $DB->GetOne("SELECT message FROM events WHERE event_id = ? LIMIT 1", array($args[0]->GetEventID()));
     $farm_name = $DB->GetOne("SELECT name FROM farms WHERE id=? LIMIT 1", array($args[0]->GetFarmID()));
     // Set subject
     if (!$farm_name) {
         $this->Mailer->setSubject("{$name} event notification (FarmID: {$args[0]->GetFarmID()})");
     } else {
         $this->Mailer->setSubject("{$name} event notification (FarmID: {$args[0]->GetFarmID()} FarmName: {$farm_name})");
     }
     // Set body
     $this->Mailer->setMessage($message);
     // Send mail
     try {
         $res = $this->Mailer->send();
     } catch (\Exception $e) {
         $res = false;
     }
     if (!$res) {
         Logger::getLogger(__CLASS__)->info("Mail sent to '{$this->Config->GetFieldByName("EventMailTo")->Value}'. Result: {$res}");
     }
 }
开发者ID:recipe,项目名称:scalr,代码行数:34,代码来源:class.MailEventObserver.php


示例11: __construct

 /**
  * Constructor
  */
 function __construct()
 {
     $this->Logger = \Scalr::getContainer()->logger('SignalHandler');
     if (!function_exists("pcntl_signal")) {
         throw new \Exception("Function pcntl_signal() is not found. PCNTL must be enabled in PHP.", E_ERROR);
     }
 }
开发者ID:mheydt,项目名称:scalr,代码行数:10,代码来源:SignalHandler.php


示例12: OnBeforeInstanceLaunch

 /**
  * {@inheritdoc}
  * @see \Scalr\Observer\AbstractEventObserver::OnBeforeInstanceLaunch()
  */
 public function OnBeforeInstanceLaunch(\BeforeInstanceLaunchEvent $event)
 {
     if ($event->DBServer->platform != \SERVER_PLATFORMS::EC2) {
         return;
     }
     $DBFarm = $event->DBServer->GetFarmObject();
     $DBFarmRole = $event->DBServer->GetFarmRoleObject();
     // Create EBS volume for MySQLEBS
     if (!$event->DBServer->IsSupported("0.6")) {
         // Only for old AMIs
         if ($DBFarmRole->GetRoleObject()->hasBehavior(\ROLE_BEHAVIORS::MYSQL) && $DBFarmRole->GetSetting(Entity\FarmRoleSetting::MYSQL_DATA_STORAGE_ENGINE) == \MYSQL_STORAGE_ENGINE::EBS) {
             $server = $event->DBServer;
             $masterServer = $DBFarm->GetMySQLInstances(true);
             $isMaster = !$masterServer || $masterServer[0]->serverId == $server->serverId;
             $farmMasterVolId = $DBFarmRole->GetSetting(Entity\FarmRoleSetting::MYSQL_MASTER_EBS_VOLUME_ID);
             $createEbs = $isMaster && !$farmMasterVolId;
             if ($createEbs) {
                 \Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->info(new FarmLogMessage($event->DBServer, sprintf("Need EBS volume for MySQL %s instance...", $isMaster ? "Master" : "Slave")));
                 $req = new CreateVolumeRequestData($event->DBServer->GetProperty(\EC2_SERVER_PROPERTIES::AVAIL_ZONE), $DBFarmRole->GetSetting(Entity\FarmRoleSetting::MYSQL_EBS_VOLUME_SIZE));
                 $aws = $event->DBServer->GetEnvironmentObject()->aws($DBFarmRole->CloudLocation);
                 $res = $aws->ec2->volume->create($req);
                 if (!empty($res->volumeId)) {
                     $DBFarmRole->SetSetting(Entity\FarmRoleSetting::MYSQL_MASTER_EBS_VOLUME_ID, $res->volumeId, Entity\FarmRoleSetting::TYPE_LCL);
                     \Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->info(new FarmLogMessage($event->DBServer, sprintf("MySQL %S volume created. Volume ID: %s...", $isMaster ? "Master" : "Slave", !empty($res->volumeId) ? $res->volumeId : null)));
                 }
             }
         }
     }
 }
开发者ID:scalr,项目名称:scalr,代码行数:33,代码来源:EbsObserver.php


示例13: run

    public function run()
    {
        $container = \Scalr::getContainer();
        $db = $container->adodb;
        $row = $db->GetRow("SHOW TABLES LIKE 'upgrades'");
        if ($row) {
            print "Tables already exist. Terminating.\n";
            exit;
        }
        $script = <<<EOL
            CREATE TABLE `upgrades` (
             `uuid` VARBINARY(16) NOT NULL COMMENT 'Unique identifier of update',
             `released` DATETIME NOT NULL COMMENT 'The time when upgrade script is issued',
             `appears` DATETIME NOT NULL COMMENT 'The time when upgrade does appear',
             `applied` DATETIME DEFAULT NULL COMMENT 'The time when update is successfully applied',
             `status` TINYINT NOT NULL COMMENT 'Upgrade status',
             `hash` VARBINARY (20) COMMENT 'SHA1 hash of the upgrade file',
             PRIMARY KEY (`uuid`),
             INDEX `idx_status` (`status`),
             INDEX `idx_appears` (`appears`)
            ) ENGINE = InnoDB;

            CREATE TABLE `upgrade_messages` (
              `uuid` VARBINARY(16) NOT NULL COMMENT 'upgrades.uuid reference',
              `created` DATETIME NOT NULL COMMENT 'Creation timestamp',
              `message` TEXT COMMENT 'Error messages',
              INDEX idx_uuid (`uuid`),
              CONSTRAINT `upgrade_messages_ibfk_1` FOREIGN KEY (`uuid`) REFERENCES `upgrades` (`uuid`) ON DELETE CASCADE
            ) ENGINE = InnoDB;
EOL;
        $lines = array_filter(preg_split('/;[\\s\\r\\n]*/m', $script));
        foreach ($lines as $stmt) {
            $db->Execute($stmt);
        }
    }
开发者ID:recipe,项目名称:scalr,代码行数:35,代码来源:upgrade_20131018.php


示例14: setUserRoles

 /**
  * Saves all relations between all users of this team and ACL roles
  *
  * @param   array   $data Roles array should look like array(user_id => array(account_role_id, ...))
  * @throws  \Scalr\Acl\Exception\AclException
  */
 public function setUserRoles(array $data = array())
 {
     if (empty($this->id)) {
         throw new \Scalr\Acl\Exception\AclException(sprintf("ID of the team is expected. It hasn't been initialized yet."));
     }
     \Scalr::getContainer()->acl->setAllRolesForTeam($this->id, $data, $this->accountId);
 }
开发者ID:mheydt,项目名称:scalr,代码行数:13,代码来源:Team.php


示例15: setUp

 /**
  * {@inheritdoc}
  * @see \Scalr\Tests\TestCase::setUp()
  */
 protected function setUp()
 {
     parent::setUp();
     if (!\Scalr::getContainer()->analytics->enabled) {
         $this->markTestSkipped("Cost analytics has not been enabled in the configuration.");
     }
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:11,代码来源:ChartPeriodIteratorTest.php


示例16: Run

 public function Run()
 {
     $container = Scalr::getContainer();
     $db = $container->adodb;
     $db->Execute("ALTER TABLE  `global_variables` ADD  `format` VARCHAR( 15 ) NULL , ADD  `validator` VARCHAR( 255 ) NULL ;");
     $db->Execute("ALTER TABLE  `apache_vhosts` DROP INDEX  `ix_name` , ADD UNIQUE  `ix_name` (  `name` ,  `env_id` ,  `farm_id`, `farm_roleid` ) ;");
 }
开发者ID:recipe,项目名称:scalr,代码行数:7,代码来源:upgrade_20130716.php


示例17: startChild

 function startChild()
 {
     // Reopen DB connection in child
     $this->db = $this->getContainer()->adodb;
     // Reconfigure observers;
     Scalr::ReconfigureObservers();
 }
开发者ID:rickb838,项目名称:scalr,代码行数:7,代码来源:DbMsrMaintenance.php


示例18: xSaveAction

 public function xSaveAction($url, $endpointId = null)
 {
     if (!$endpointId) {
         $endpoint = new WebhookEndpoint();
         $endpoint->level = WebhookEndpoint::LEVEL_ENVIRONMENT;
         $endpoint->accountId = $this->getEnvironment()->clientId;
         $endpoint->envId = $this->getEnvironmentId();
         $endpoint->securityKey = Scalr::GenerateRandomKey(64);
     } else {
         $endpoint = WebhookEndpoint::findPk($endpointId);
         if ($endpoint->envId != $this->getEnvironmentId() || $endpoint->accountId != $this->getEnvironment()->clientId) {
             throw new Scalr_Exception_Core('Insufficient permissions to edit endpoint');
         }
     }
     foreach (WebhookEndpoint::findByUrl($url) as $ep) {
         if ($ep->endpointId != $endpoint->endpointId && $ep->envId == $this->getEnvironmentId()) {
             $this->request->addValidationErrors('url', 'Endpoint url must be unique within environment');
             break;
         }
     }
     if ($this->request->isValid()) {
         if ($endpoint->url != $url) {
             $endpoint->isValid = false;
             $endpoint->url = $url;
         }
         ////temporarily disable url validation per Igor`s request(see also webhooks/endpoints/view.js)
         $endpoint->isValid = true;
         $endpoint->save();
         $this->response->data(array('endpoint' => array('endpointId' => $endpoint->endpointId, 'url' => $endpoint->url, 'isValid' => $endpoint->isValid, 'validationToken' => $endpoint->validationToken, 'securityKey' => $endpoint->securityKey)));
     } else {
         $this->response->data($this->request->getValidationErrors());
         $this->response->failure();
     }
 }
开发者ID:rickb838,项目名称:scalr,代码行数:34,代码来源:Endpoints.php


示例19: __construct

 /**
  * Constructor. Instantiates ApiLogger, prepares backend
  *
  * @param ApiLoggerConfiguration $config  Api logger config object
  */
 public function __construct($config)
 {
     parent::__construct(\Scalr::config('scalr.logger.api'));
     $this->ipAddress = $config->ipAddress;
     $this->requestId = $config->requestId;
     $this->requestType = $config->requestType;
 }
开发者ID:scalr,项目名称:scalr,代码行数:12,代码来源:ApiLogger.php


示例20: testModifications

 /**
  * @test
  * @dataProvider providerModifications
  *
  * @param array $data
  * @param array $modifications
  * @param array $expected
  */
 public function testModifications($data, $modifications, $expected)
 {
     $mutator = new TestMutator($modifications);
     $mutator->setSpec($data);
     $mutator->apply(\Scalr::getContainer()->config(), 'test');
     $this->assertEquals($data, $expected);
 }
开发者ID:mheydt,项目名称:scalr,代码行数:15,代码来源:SpecMutatorTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Scalr_Account_User类代码示例发布时间:2022-05-23
下一篇:
PHP SavedSearch类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap