Exemplo n.º 1
2
 public function autoresAction()
 {
     $di = new Phalcon\DI();
     $Seccion = new Seccion('autores', false, $this->dispatcher);
     //      $Seccion->alert = \Rpp\Services\Get\Alert::active();
     $di->set('model', $Seccion);
     $di->set('viewCache', $this->viewCache);
     $this->view->setDI($di);
 }
Exemplo n.º 2
1
 public function resultadosAction()
 {
     $di = new Phalcon\DI();
     $di->set('model', new \Rpp\Pages\Debate('resultados'));
     $di->set('viewCache', $this->viewCache);
     $di->set('redis', $this->redis);
     $this->view->setDI($di);
 }
Exemplo n.º 3
0
 public function show404Action()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $di->set('model', new \Rpp\Pages\Notfound());
     $this->view->setDI($di);
 }
Exemplo n.º 4
0
 public function loadAction()
 {
     $node = $this->request->getPost("node");
     try {
         $node = json_decode($node, true);
         $node = (object) $node;
         $node->fecha_publicacion = time();
         $nota = new \Rpp\Pages\Preview\Nota();
         $nota->titulo = $node->titulo . ' | La 10.pe';
         $nota->package = 'notapreview';
         $nota->tipo = $node->tipo;
         $nota->keywords = array();
         $nota->keywords_slug = array();
         if (is_array($node->tags)) {
             foreach ($node->tags as $key => $value) {
                 $nota->keywords[] = $value['nombre'];
                 $nota->keywords_slug[] = $value['slug'];
             }
         }
         $nota->tags = $node->tags;
         $nota->keywords = implode(",", $nota->keywords);
         $nota->nid = 0;
         $di = new Phalcon\DI();
         $di->set('notapreview', $node);
         $di->set('model', $nota);
         $di->set('viewCache', $this->viewCache);
         $this->view->setDI($di);
         $this->view->setVar("nid", 801073);
         echo $response_render = $this->view->getRender('nota', 'detalle');
         //echo json_encode(array('status'=>'ok','data'=>$response_render));
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Exemplo n.º 5
0
 public function testBehaviors()
 {
     if (!class_exists('Mongo')) {
         $this->markTestSkipped("Mongo class does not exist, test skipped");
         return;
     }
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('mongo', function () {
         $mongo = new MongoClient();
         return $mongo->phalcon_test;
     });
     $di->set('collectionManager', function () {
         return new Phalcon\Mvc\Collection\Manager();
     });
     //Timestampable
     $subscriber = new Subs();
     $subscriber->email = '*****@*****.**';
     $subscriber->status = 'I';
     $this->assertTrue($subscriber->save());
     $this->assertEquals(preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $subscriber->created_at), 1);
     //Softdelete
     $subscriber = Subs::findFirst();
     $this->assertTrue($subscriber->delete());
     $this->assertEquals($subscriber->status, 'D');
     $this->assertEquals(Subs::count(), 1);
 }
Exemplo n.º 6
0
 public function testControllers()
 {
     $di = new Phalcon\DI();
     $di->set('view', function () {
         $view = new Phalcon\Mvc\View();
         $view->setViewsDir('unit-tests/views/');
         return $view;
     });
     $di->set('request', function () {
         return new Phalcon\Http\Request();
     });
     $di->set('filter', function () {
         return new Phalcon\Filter();
     });
     if (!class_exists('Test4Controller', false)) {
         require __DIR__ . '/controllers/Test4Controller.php';
     }
     $controller = new Test4Controller();
     $controller->setDI($di);
     $_POST['email'] = ';ans@ecom.com';
     $this->assertEquals($controller->requestAction(), '*****@*****.**');
     $view = $di->getShared('view');
     $controller->viewAction();
     $this->assertEquals(count($view->getParamsToView()), 1);
 }
Exemplo n.º 7
0
 protected function _prepareDI(&$trace)
 {
     Phalcon\DI::reset();
     $eventsManager = new Phalcon\Events\Manager();
     $eventsManager->attach('model', function ($event, $model) use(&$trace) {
         if (!isset($trace[$event->getType()][get_class($model)])) {
             $trace[$event->getType()][get_class($model)] = 1;
         } else {
             $trace[$event->getType()][get_class($model)]++;
         }
     });
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () use($eventsManager) {
         $modelsManager = new Phalcon\Mvc\Model\Manager();
         $modelsManager->setEventsManager($eventsManager);
         return $modelsManager;
     }, true);
     $di->set('modelsMetadata', function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     }, true);
     $di->set('db', function () {
         require 'unit-tests/config.db.php';
         //return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
         return new Twm\Db\Adapter\Pdo\Mssql($configMssql);
     }, true);
 }
 public function testMetadataManual()
 {
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     });
     $di->set('modelsMetadata', function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     });
     $di->set('modelsQuery', 'Phalcon\\Mvc\\Model\\Query');
     $di->set('modelsQueryBuilder', 'Phalcon\\Mvc\\Model\\Query\\Builder');
     $di->set('modelsCriteria', 'Phalcon\\Mvc\\Model\\Criteria');
     $metaData = $di->getShared('modelsMetadata');
     $robotto = new Robotto($di);
     //Robots
     $pAttributes = array(0 => 'id', 1 => 'name', 2 => 'type', 3 => 'year');
     $attributes = $metaData->getAttributes($robotto);
     $this->assertEquals($attributes, $pAttributes);
     $ppkAttributes = array(0 => 'id');
     $pkAttributes = $metaData->getPrimaryKeyAttributes($robotto);
     $this->assertEquals($ppkAttributes, $pkAttributes);
     $pnpkAttributes = array(0 => 'name', 1 => 'type', 2 => 'year');
     $npkAttributes = $metaData->getNonPrimaryKeyAttributes($robotto);
     $this->assertEquals($pnpkAttributes, $npkAttributes);
     $this->assertEquals($metaData->getIdentityField($robotto), 'id');
 }
Exemplo n.º 9
0
 public function indexAction()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $di->set('model', new Buscador());
     $this->view->setDI($di);
 }
Exemplo n.º 10
0
 protected function _getCache($adapter = 'File')
 {
     @unlink('unit-tests/cache/test-resultset');
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     }, true);
     $di->set('modelsMetadata', function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     }, true);
     $di->set('db', function () {
         require 'unit-tests/config.db.php';
         return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
     }, true);
     $frontCache = new Phalcon\Cache\Frontend\Data(array('lifetime' => 3600));
     switch ($adapter) {
         case 'File':
             $cache = new Phalcon\Cache\Backend\File($frontCache, array('cacheDir' => 'unit-tests/cache/'));
             break;
         case 'Memcached':
             $cache = new Phalcon\Cache\Backend\Memcache($frontCache, array("host" => "localhost", "port" => "11211"));
             break;
         case 'Libmemcached':
             $cache = new Phalcon\Cache\Backend\Libmemcached($frontCache, array("servers" => array(array("host" => "localhost", "port" => "11211", "weight" => "1"))));
             break;
         default:
             throw new Exception("Unknown cache adapter");
     }
     $di->set('modelsCache', $cache);
     $this->_di = $di;
     return $cache;
 }
Exemplo n.º 11
0
 public function detalleAction($nid, $position = 1)
 {
     $start_memory = memory_get_usage();
     /*$nota = new \Rpp\Pages\Nota($nid,$this->dispatcher);                                 
       $di = new Phalcon\DI();
       $nota->package ='nota';
       $nota->set_position($position);
       $di->setShared('model',$nota);
       $di->setShared('viewCache',$this->viewCache);
       $this->view->setDI($di);
       
       $Analytics = new \Rpp\Services\Analytics\Visits\Load\Nota($nid);
       $Analytics->calculate();*/
     if (!Rpp\Pages\Nota::validate($nid)) {
         $this->dispatcher->forward(array('controller' => 'error', 'action' => 'show404'));
     }
     $nota = function () use($nid) {
         return new \Rpp\Pages\Nota($nid);
     };
     $di = new Phalcon\DI();
     $di->set('model', $nota);
     $di->set('viewCache', $this->viewCache);
     $this->view->setDI($di);
     $Analytics = new \Rpp\Services\Analytics\Visits\Load\Nota($nid);
     $Analytics->calculate();
     //var_dump( memory_get_usage() - $start_memory );die();
 }
Exemplo n.º 12
0
 public function indexAction()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $di->set('model', new \Rpp\Pages\Concurso());
     $this->view->setDI($di);
 }
Exemplo n.º 13
0
 public function nAction($slug)
 {
     $di = new Phalcon\DI();
     $di->set('model', new \Rpp\Pages\Tag($slug, $this->dispatcher));
     $di->set('viewCache', $this->viewCache);
     $this->view->setDI($di);
 }
Exemplo n.º 14
0
 public function testCollectionsEvents()
 {
     if (!class_exists('Mongo')) {
         $this->markTestSkipped("Mongo class does not exist, test skipped");
         return;
     }
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('mongo', function () {
         $mongo = new Mongo();
         return $mongo->phalcon_test;
     });
     $di->set('collectionManager', function () {
         return new Phalcon\Mvc\Collection\Manager();
     });
     $songs = Store\Songs::find();
     $this->assertTrue(is_array($songs));
     foreach ($songs as $song) {
         $this->assertTrue($song->delete());
     }
     $trace = array();
     $song = new Store\Songs();
     $song->trace =& $trace;
     $song->artist = 'Radiohead';
     $song->name = 'Lotus Flower';
     $this->assertTrue($song->save());
     $this->assertEquals($trace, array('Store\\Songs::beforeValidation' => 1, 'Store\\Songs::beforeValidationOnCreate' => 1, 'Store\\Songs::afterValidationOnCreate' => 1, 'Store\\Songs::afterValidation' => 1, 'Store\\Songs::beforeSave' => 1, 'Store\\Songs::beforeCreate' => 1, 'Store\\Songs::afterCreate' => 1, 'Store\\Songs::afterSave' => 1));
     $this->assertTrue($song->save());
     $this->assertEquals($trace, array('Store\\Songs::beforeValidation' => 2, 'Store\\Songs::beforeValidationOnCreate' => 1, 'Store\\Songs::afterValidationOnCreate' => 1, 'Store\\Songs::afterValidation' => 2, 'Store\\Songs::beforeSave' => 2, 'Store\\Songs::beforeCreate' => 1, 'Store\\Songs::afterCreate' => 1, 'Store\\Songs::afterSave' => 2, 'Store\\Songs::afterValidationOnUpdate' => 1, 'Store\\Songs::beforeUpdate' => 1, 'Store\\Songs::afterUpdate' => 1));
 }
Exemplo n.º 15
0
 public function indexAction()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $Galerias = new Galerias();
     $di->set('model', $Galerias);
     $this->view->setDI($di);
 }
Exemplo n.º 16
0
 public function ultimasAction($intervalo = 12)
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $Archivo = new Archivo();
     $Archivo->ultimas($intervalo);
     //    $Archivo->alert = \Rpp\Services\Get\Alert::active();
     $di->set('model', $Archivo);
     $this->view->setDI($di);
 }
Exemplo n.º 17
0
 public function generalAction($fecha)
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $Archivo = new Archivo();
     $Archivo->home($fecha);
     $di->set('model', $Archivo);
     $this->view->setDI($di);
     echo $response_render = $this->view->getRender('archivo', 'seccion');
 }
Exemplo n.º 18
0
 protected function _getDI()
 {
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     });
     $di->set('modelsMetadata', function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     });
     return $di;
 }
Exemplo n.º 19
0
 public function encuestaAction($slug = 'elecciones-peru-2016')
 {
     $di = new Phalcon\DI();
     $tag = new \Rpp\Pages\Tag($slug, $this->dispatcher);
     $tag->img_social = 'http://rpp.pe/elecciones-peru-2016/img/sondeo_interactivo.jpg';
     $tag->urlcanonical = '/elecciones-peru-2016/encuesta';
     $this->url_social = '/elecciones-peru-2016/encuesta';
     $di->set('model', $tag);
     $di->set('viewCache', $this->viewCache);
     $this->view->setDI($di);
 }
Exemplo n.º 20
0
 protected function _prepareDI()
 {
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     }, true);
     $di->set('db', function () {
         require 'unit-tests/config.db.php';
         return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
     }, true);
 }
 public function testOverrideStaticCache()
 {
     require 'unit-tests/config.db.php';
     if (empty($configMysql)) {
         $this->markTestSkipped('Test skipped');
         return;
     }
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di['db'] = function () {
         require 'unit-tests/config.db.php';
         return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
     };
     $di['modelsManager'] = function () {
         return new Phalcon\Mvc\Model\Manager();
     };
     $di['modelsMetadata'] = function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     };
     $di->set('modelsQuery', 'Phalcon\\Mvc\\Model\\Query');
     $di->set('modelsQueryBuilder', 'Phalcon\\Mvc\\Model\\Query\\Builder');
     $di->set('modelsCriteria', 'Phalcon\\Mvc\\Model\\Criteria');
     $di['modelsCache'] = function () {
         $frontCache = new Phalcon\Cache\Frontend\Data();
         return new Phalcon\Cache\Backend\File($frontCache, array('cacheDir' => 'unit-tests/cache/'));
     };
     $robot = Cacheable\Robots::findFirst(2);
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robot = Cacheable\Robots::findFirst(2);
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robot = Cacheable\Robots::findFirst(array('id = 2'));
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robot = Cacheable\Robots::findFirst(array('id = 2'));
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robot = Cacheable\Robots::findFirst(array('order' => 'id DESC'));
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robot = Cacheable\Robots::findFirst(array('order' => 'id DESC'));
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robot = Cacheable\Robots::findFirst(1);
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robotParts = $robot->getRobotsParts();
     $this->assertEquals(get_class($robotParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $robotParts = $robot->getRobotsParts();
     $this->assertEquals(get_class($robotParts), 'Phalcon\\Mvc\\Model\\Resultset\\Simple');
     $part = $robotParts[0]->getParts();
     $this->assertEquals(get_class($part), 'Cacheable\\Parts');
     $part = $robotParts[0]->getParts();
     $this->assertEquals(get_class($part), 'Cacheable\\Parts');
     $robot = $robotParts[0]->getRobots();
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
     $robot = $robotParts[0]->getRobots();
     $this->assertEquals(get_class($robot), 'Cacheable\\Robots');
 }
Exemplo n.º 22
0
 public static function setUpBeforeClass()
 {
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('mongo', function () {
         $mongo = new MongoClient();
         return $mongo->phalcon_test;
     });
     $di->set('collectionManager', function () {
         return new Phalcon\Mvc\Collection\Manager();
     });
 }
Exemplo n.º 23
0
 public function minAction($nid, $position = 1)
 {
     if (!Rpp\Pages\Nota::validate($nid)) {
         $this->dispatcher->forward(array('controller' => 'error', 'action' => 'show404'));
     }
     $nota = new \Rpp\Pages\Nota($nid);
     $di = new Phalcon\DI();
     $nota->package = 'nota';
     $nota->set_position($position);
     $di->set('model', $nota);
     $di->set('viewCache', $this->viewCache);
     $this->view->setDI($di);
 }
Exemplo n.º 24
0
Arquivo: app.php Projeto: nisnaker/tu
 protected function registerServices()
 {
     $di = new Phalcon\DI();
     $di->set('mongo', function () {
         $mongo = new MongoClient(MONGO_DSN);
         return $mongo->selectDB(MONGO_DB);
     });
     $di->set('router', 'Phalcon\\Mvc\\Router', true);
     $di->set('request', 'Phalcon\\Http\\Request', true);
     $di->set('response', 'Phalcon\\Http\\Response', true);
     $di->set('collectionManager', 'Phalcon\\Mvc\\Collection\\Manager', true);
     $this->setDI($di);
 }
 protected function _getDI()
 {
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     });
     $di->set('db', function () {
         require __DIR__ . '/config.db.php';
         return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
     });
     return $di;
 }
Exemplo n.º 26
0
 protected function _getDI($dbService)
 {
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     });
     $di->set('modelsMetadata', function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     });
     $di->set('db', $dbService);
     return $di;
 }
Exemplo n.º 27
0
 public function setup()
 {
     $db = $this->get_db_params();
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     });
     $di->set('db', function () use($db) {
         return new Phalcon\Db\Adapter\Pdo\Mysql(['host' => $db['host'], 'username' => $db['username'], 'password' => $db['password'], 'dbname' => $db['dbname']]);
     });
     $di->set('modelsMetadata', function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     });
 }
Exemplo n.º 28
-1
 protected function _getDI()
 {
     Phalcon\DI::reset();
     $di = new Phalcon\DI();
     $di->set('modelsManager', function () {
         return new Phalcon\Mvc\Model\Manager();
     });
     $di->set('modelsMetadata', function () {
         return new Phalcon\Mvc\Model\Metadata\Memory();
     });
     $di->set('db', function () {
         require 'unit-tests/config.db.php';
         //return new Twm\Db\Adapter\Pdo\Mssql($configMssql);
         $connection = new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
         $eventsManager = new Phalcon\Events\Manager();
         //Listen all the database events
         $eventsManager->attach('db', function ($event, $connection) {
             if ($event->getType() == 'beforeQuery') {
                 echo $connection->getSQLStatement();
             }
         });
         //Assign the eventsManager to the db adapter instance
         $connection->setEventsManager($eventsManager);
         return $connection;
     });
     return $di;
 }
Exemplo n.º 29
-1
 public function categoriaAction($slug_categoria)
 {
     $di = new Phalcon\DI();
     $Seccion = new Seccion('blog', $slug_categoria, $this->dispatcher);
     $di->set('model', $Seccion);
     $di->set('viewCache', $this->viewCache);
     $this->view->setDI($di);
     $Analytics = new \Rpp\Services\Analytics\Visits\Load\MasVisitadas('blog');
     $Analytics->calculate();
 }
Exemplo n.º 30
-1
 public function portadaAction($slug = 'lima')
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $climas = new \Rpp\Pages\Climas();
     $climas->slug = $slug;
     $climas->load_pronostico();
     $di->set('model', $climas);
     $this->view->setDI($di);
 }