Scalr\Api\Service\User\V1beta0\Adapter\OrchestrationRuleAdapter::targetToData PHP Method

targetToData() public static method

public static targetToData ( Scalr\Model\Entity\OrchestrationRule $entity, $object )
$entity Scalr\Model\Entity\OrchestrationRule
    public static function targetToData(OrchestrationRule $entity, $object)
    {
        $rules = array_flip(static::$targetMap);
        $object->target = (object) ['targetType' => $rules[$entity->target]];
    }

Usage Example

Ejemplo n.º 1
0
 public static function targetToData(OrchestrationRule $entity, $object)
 {
     /* @var $entity FarmRoleScript */
     parent::targetToData($entity, $object);
     if ($entity->target == static::TARGET_VALUE_SPECIFIED_FARM_ROLE) {
         /* @var $entity FarmRoleScript */
         $farmRole = new FarmRole();
         $targets = new FarmRoleScriptingTarget();
         /* @var $target FarmRole */
         foreach (FarmRole::find([['farmId' => $entity->farmId], AbstractEntity::STMT_FROM => "{$farmRole->table()} JOIN {$targets->table('t')} ON {$targets->columnTarget('t')} = {$farmRole->columnAlias()}", AbstractEntity::STMT_WHERE => "{$targets->columnFarmRoleScriptId('t')} = {$targets->qstr('farmRoleScriptId', $entity->id)} AND {$targets->columnTargetType('t')} = {$targets->qstr('targetType', OrchestrationRule::TARGET_ROLES)}"]) as $target) {
             $object->target->roles[] = ['id' => $target->id];
         }
     }
 }