/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     require_once dirname(__FILE__) . '/../../../config/ProjectConfiguration.class.php';
     $configuration = ProjectConfiguration::getApplicationConfiguration('public', 'prod', true);
     sfContext::createInstance($configuration);
     $liveLang = $arguments['live_lang'];
     $langToDeploy = $arguments['lang_to_deploy'];
     $liveLangs = SfConfig::get('app_site_langs');
     $langsUnderDev = SfConfig::get('app_site_langsUnderDev');
     if (in_array($liveLang, $liveLangs) === false) {
         die("The live lang doesn't seem to be live!");
     }
     if (in_array($langToDeploy, $langsUnderDev) === false) {
         die("You can deploy only a language under development");
     }
     $c = new Criteria();
     $c->add(PcTranslationPeer::LANGUAGE_ID, $langToDeploy);
     $translationsToDeploy = PcTranslationPeer::doSelect($c);
     $i = 0;
     foreach ($translationsToDeploy as $translationToDeploy) {
         $this->log("Deploying the string " . $translationToDeploy->getStringId() . " from {$langToDeploy} to {$liveLang}");
         $liveTranslation = PcTranslationPeer::retrieveByPK($liveLang, $translationToDeploy->getStringId());
         $liveTranslation->setString($translationToDeploy->getString())->save();
         $translationToDeploy->delete();
         $i++;
     }
     $this->log("All done. {$i} strings deployed.");
 }
Ejemplo n.º 2
0
 /**
  * Gets an array of PcTranslation objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this PcLanguage has previously been saved, it will retrieve
  * related PcTranslations from storage. If this PcLanguage is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array PcTranslation[]
  * @throws     PropelException
  */
 public function getPcTranslations($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PcLanguagePeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collPcTranslations === null) {
         if ($this->isNew()) {
             $this->collPcTranslations = array();
         } else {
             $criteria->add(PcTranslationPeer::LANGUAGE_ID, $this->id);
             PcTranslationPeer::addSelectColumns($criteria);
             $this->collPcTranslations = PcTranslationPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(PcTranslationPeer::LANGUAGE_ID, $this->id);
             PcTranslationPeer::addSelectColumns($criteria);
             if (!isset($this->lastPcTranslationCriteria) || !$this->lastPcTranslationCriteria->equals($criteria)) {
                 $this->collPcTranslations = PcTranslationPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastPcTranslationCriteria = $criteria;
     return $this->collPcTranslations;
 }
 /**
  * Retrieve object using using composite pkey values.
  * @param      string $language_id
  * @param      string $string_id
  * @param      PropelPDO $con
  * @return     PcTranslation
  */
 public static function retrieveByPK($language_id, $string_id, PropelPDO $con = null)
 {
     $key = serialize(array((string) $language_id, (string) $string_id));
     if (null !== ($obj = PcTranslationPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(PcTranslationPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(PcTranslationPeer::DATABASE_NAME);
     $criteria->add(PcTranslationPeer::LANGUAGE_ID, $language_id);
     $criteria->add(PcTranslationPeer::STRING_ID, $string_id);
     $v = PcTranslationPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }