public function getCachedTopNew() { throw new \Exception('not implemented'); $cache = $this->cache->get('tekstove.lyric.topNew'); if ($cache) { return $cache; } $newestQuery = new LyricQuery(); /* @var $newestQuery \Tekstove\TekstoveBundle\Model\LyricQuery */ $newestQuery->orderById(Criteria::DESC); $newestQuery->limit(10); $lastLyricsCollection = $newestQuery->find(); $lastLyrics = $lastLyricsCollection->getArrayCopy(); $this->cache->set('tekstove.lyric.topNew', $lastLyrics, 60 * 15); return $lastLyrics; }
public function indexAction(Request $request, $id) { if ($this->getUser()) { $user = $this->getUser(); } else { $user = new User(); } if ($id) { $lyricQuery = new LyricQuery(); $lyric = $lyricQuery->findOneById($id); } else { $lyric = new Lyric(); } $allowedFields = $user->getAllowedLyricFields($lyric); $data = ['item' => ['fields' => $allowedFields]]; return $this->handleData($request, $data); }
/** * Gets the number of Lyric objects related by a many-to-many relationship * to the current object by way of the lyric_language cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param ConnectionInterface $con Optional connection object * * @return int the number of related Lyric objects */ public function countLyrics(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collLyricsPartial && !$this->isNew(); if (null === $this->collLyrics || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collLyrics) { return 0; } else { if ($partial && !$criteria) { return count($this->getLyrics()); } $query = ChildLyricQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByLanguage($this)->count($con); } } else { return count($this->collLyrics); } }
public function deleteAction(Request $request, $id) { $this->getContext()->setGroups(['Details']); $lyricQuery = new LyricQuery(); /* @var $lyric Lyric */ $lyric = $lyricQuery->findOneById($id); try { if ($this->getUser()) { $user = $this->getUser(); } else { $user = new User(); } $allowedFields = $user->getAllowedLyricFields($lyric); if (!in_array('delete', $allowedFields)) { throw new \Exception("Delete not allowed"); } $lyric->delete(); return $this->handleData($request, $lyric); } catch (LyricHumanReadableException $e) { $view = $this->handleData($request, $e->getErrors()); $view->setStatusCode(400); return $view; } }
/** * Returns a new ChildLyricQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return ChildLyricQuery */ public static function create($modelAlias = null, Criteria $criteria = null) { if ($criteria instanceof ChildLyricQuery) { return $criteria; } $query = new ChildLyricQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * 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 = ChildLyricQuery::create(); $criteria->add(LyricTableMap::COL_ID, $this->id); return $criteria; }
/** * Performs an INSERT on the database, given a Lyric or Criteria object. * * @param mixed $criteria Criteria or Lyric 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(LyricTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from Lyric object } if ($criteria->containsKey(LyricTableMap::COL_ID) && $criteria->keyContainsValue(LyricTableMap::COL_ID)) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . LyricTableMap::COL_ID . ')'); } // Set the correct dbName $query = LyricQuery::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); }); }
/** * Get the associated Lyric object * * @param ConnectionInterface $con Optional Connection object. * @return Lyric The associated Lyric object. * @throws PropelException */ public function getLyric(ConnectionInterface $con = null) { if ($this->aLyric === null && $this->lyric_id !== null) { $this->aLyric = LyricQuery::create()->findPk($this->lyric_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aLyric->addArtistLyrics($this); */ } return $this->aLyric; }