/** * @param Environment $environment The environment object to add. */ protected function doAddEnvironment($environment) { $this->collEnvironments[] = $environment; $environment->setSite($this); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Environment $obj A Environment object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null EnvironmentPeer::$instances[$key] = $obj; } }
/** * Filter the query by a related Environment object * * @param Environment|PropelObjectCollection $environment the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return SiteQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByEnvironment($environment, $comparison = null) { if ($environment instanceof Environment) { return $this->addUsingAlias(SitePeer::ID, $environment->getSiteid(), $comparison); } elseif ($environment instanceof PropelObjectCollection) { return $this->useEnvironmentQuery()->filterByPrimaryKeys($environment->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByEnvironment() only accepts arguments of type Environment or PropelCollection'); } }
/** * Populate available Site Environments from a Provider. * * @param string $site_name * The machine name of the site in question. */ public function apiGetSiteEnvironments($site_name) { $site = SiteQuery::create()->filterByProvider($this->name)->filterByName($site_name)->findOne(); $result = switchboard_request($this, array('method' => 'GET', 'realm' => 'environments', 'resource' => 'site', 'uuid' => $site->getUuid())); $environment_data = json_decode($result->body); if (!is_scalar($environment_data)) { foreach ($environment_data as $environment_name => $environment) { $new_environment = new Environment(); $new_environment->setName($environment_name); $new_environment->setBranch('master'); $new_environment->setHost("appserver.{$environment_name}.{$site->getUuid()}.drush.in"); $new_environment->setUsername("{$environment_name}.{$site_name}"); $site->addEnvironment($new_environment); } } $site->save(); }
/** * Exclude object from result * * @param Environment $environment Object to remove from the list of results * * @return EnvironmentQuery The current query, for fluid interface */ public function prune($environment = null) { if ($environment) { $this->addUsingAlias(EnvironmentPeer::ID, $environment->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Populate available Site Environments from a Provider. * * @param string $site_name * The machine name of the site in question. */ public function apiGetSiteEnvironments($site_name) { $site = SiteQuery::create()->filterByProvider($this->name)->filterByName($site_name)->findOne(); $result = switchboard_request($this, array('method' => 'GET', 'resource' => '/sites/' . $site->getRealm() . ':' . $site_name . '/envs')); $environment_data = json_decode($result->body); foreach ($environment_data as $environment) { $new_environment = new Environment(); $new_environment->setName($environment->name); $new_environment->setBranch($environment->vcs_path); $new_environment->setHost($environment->ssh_host); $new_environment->setUsername("{$site_name}.{$environment->name}"); $site->addEnvironment($new_environment); } $site->save(); }