Ejemplo n.º 1
0
 /**
  * Returns a new ChildAnimationQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildAnimationQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildAnimationQuery) {
         return $criteria;
     }
     $query = new ChildAnimationQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Ejemplo n.º 2
0
 public function upload($model)
 {
     if ($model->atlas['name'] == "") {
         $model->error->message = "You must specify an atlas file";
         return $this->View($model, "UploadAnimation");
     }
     $atlasFile = $model->atlas['tmp_name'];
     if ($model->texture['name'] == "") {
         $model->error->message = "You must specify a texture file";
         return $this->View($model, "UploadAnimation");
     }
     $textureFile = $model->texture['tmp_name'];
     if ($model->json['name'] == "") {
         $model->error->message = "You must specify a texture file";
         return $this->View($model, "UploadAnimation");
     }
     $jsonFile = $model->json['tmp_name'];
     if ($model->animation == "") {
         $model->error->message = "You must specify an animation name";
         return $this->View($model, "UploadAnimation");
     }
     $animationName = $model->animation;
     $atlasDestName = $animationName . '.atlas';
     $textureDestName = $animationName . '.png';
     $jsonDestName = $animationName . '.json';
     $p = new ImageProcessor($textureFile);
     $p->resizeKeepAspect(50);
     $thumbSource = $p->getFilename();
     $thumbDestName = $animationName . "Thumb.jpg";
     /** @var \com\readysteadyrainbow\entities\Animation $anim */
     $anim = AnimationQuery::create()->findOneByName($animationName);
     if ($anim == null) {
         $anim = new \com\readysteadyrainbow\entities\Animation();
         $anim->setName($animationName);
         $anim->setVersion(1);
         $anim->save();
     } else {
         $anim->setVersion($anim->getVersion() + 1);
         $anim->save();
     }
     global $s3;
     try {
         $s3->putObject(['Bucket' => 'appy-little-eaters', 'Key' => "animations/" . $animationName . "/" . $atlasDestName, 'Body' => fopen($atlasFile, 'r'), 'ACL' => 'public-read']);
         $s3->putObject(['Bucket' => 'appy-little-eaters', 'Key' => "animations/" . $animationName . "/" . $textureDestName, 'Body' => fopen($textureFile, 'r'), 'ACL' => 'public-read']);
         $s3->putObject(['Bucket' => 'appy-little-eaters', 'Key' => "animations/" . $animationName . "/" . $jsonDestName, 'Body' => fopen($jsonFile, 'r'), 'ACL' => 'public-read']);
         $s3->putObject(['Bucket' => 'appy-little-eaters', 'Key' => "animations/" . $animationName . "/" . $thumbDestName, 'Body' => fopen($thumbSource, 'r'), 'ACL' => 'public-read']);
     } catch (S3Exception $e) {
         $model->error->message = $e->getMessage();
         return $this->View($model, "UploadAnimation");
     }
     return $this->RedirectToAction("listAnimations");
 }
Ejemplo n.º 3
0
 /**
  * Performs an INSERT on the database, given a Animation or Criteria object.
  *
  * @param mixed               $criteria Criteria or Animation object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(AnimationTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Animation object
     }
     // Set the correct dbName
     $query = AnimationQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
Ejemplo n.º 4
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildAnimationQuery::create();
     $criteria->add(AnimationTableMap::COL_NAME, $this->name);
     return $criteria;
 }