Esempio 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);
 }
Esempio 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);
 }
Esempio n. 3
1
 /**
  * Registers the module-only services
  *
  * @param Phalcon\DI $di
  */
 public function registerServices($di)
 {
     $dispatcher = $di->getDispatcher();
     $dispatcher->setDefaultNamespace('Wscn\\Controllers');
     View::registerComponent('post', 'Eva\\EvaBlog\\Components\\Post');
     View::registerComponent('search', 'Eva\\EvaBlog\\Components\\Search');
     $di->set('widget', function () {
         return new Components\Widget();
     });
 }
 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);
 }
Esempio n. 5
0
 public function portadaAction()
 {
     $this->mqconf = new \Phalcon\Config\Adapter\Ini(CONFIG_PATH . DIRS . "ini/mq.ini");
     $connection = new AMQPConnection($this->mqconf->host, $this->mqconf->port, $this->mqconf->user, $this->mqconf->pasw);
     $channel = $connection->channel();
     $channel->queue_declare(SITESLUG . '_publicacion_destacados', false, true, false, false);
     echo ' [*] Servicio listener para la publicacion de destacados ,  CTRL+C para cancelar', "\n";
     $callback = function ($msg) {
         try {
             $node = json_decode($msg->body);
             print_r($node);
             $destacados = new \Rpp\Services\Publish\Destacados(@$node->slug);
             $di = new Phalcon\DI();
             $di->set('viewCache', $this->viewCache);
             $destacados->setDI($di);
             $destacados->load();
         } catch (\Exception $e) {
             var_dump($e);
         }
         break;
     };
     $channel->basic_consume(SITESLUG . '_publicacion_destacados', '', false, true, false, false, $callback);
     while (count($channel->callbacks)) {
         $channel->wait();
     }
 }
Esempio n. 6
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));
 }
Esempio n. 7
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;
 }
 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);
 }
Esempio n. 9
0
 public function indexAction()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $di->set('model', new \Rpp\Pages\Concurso());
     $this->view->setDI($di);
 }
Esempio n. 10
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);
 }
Esempio n. 11
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);
 }
Esempio n. 12
0
 public function eplAction($nid, $numero)
 {
     $add = new \Rpp\Pages\Add($nid, $numero);
     $di = new Phalcon\DI();
     $di->set('model', $add);
     $this->view->setDI($di);
 }
Esempio n. 13
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();
     }
 }
Esempio n. 14
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();
 }
Esempio n. 15
0
 public function show404Action()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $di->set('model', new \Rpp\Pages\Notfound());
     $this->view->setDI($di);
 }
Esempio n. 16
0
 public function notasAction()
 {
     $this->mqconf = new \Phalcon\Config\Adapter\Ini(CONFIG_PATH . DIRS . "ini/mq.ini");
     $connection = new AMQPConnection($this->mqconf->host, $this->mqconf->port, $this->mqconf->user, $this->mqconf->pasw);
     $channel = $connection->channel();
     $channel->queue_declare(SITESLUG . '_eliminar_noticia', false, true, false, false);
     echo ' [*] Servicio listener para despublicacion ,  CTRL+C para cancelar', "\n";
     $callback = function ($msg) {
         try {
             $node = json_decode($msg->body);
             var_dump($node);
             $publicacion = new \Rpp\Services\Unpublish\Noticia((int) $node->nid);
             $di = new Phalcon\DI();
             $di->set('viewCache', $this->viewCache);
             $publicacion->setDI($di);
             $publicacion->builder();
         } catch (\Exception $e) {
             var_dump($e);
         }
         break;
     };
     $channel->basic_consume(SITESLUG . '_eliminar_noticia', '', false, true, false, false, $callback);
     while (count($channel->callbacks)) {
         $channel->wait();
     }
 }
Esempio n. 17
0
 public function indexAction()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $di->set('model', new Buscador());
     $this->view->setDI($di);
 }
Esempio n. 18
0
 public function indexAction()
 {
     $di = new Phalcon\DI();
     $di->set('viewCache', $this->viewCache);
     $Galerias = new Galerias();
     $di->set('model', $Galerias);
     $this->view->setDI($di);
 }
Esempio n. 19
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');
 }
Esempio n. 20
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);
 }
 protected function _prepareDI()
 {
     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('modelsQuery', 'Phalcon\\Mvc\\Model\\Query');
     $di->set('modelsQueryBuilder', 'Phalcon\\Mvc\\Model\\Query\\Builder');
     $di->set('modelsCriteria', 'Phalcon\\Mvc\\Model\\Criteria');
     $di->set('db', function () {
         throw new Exception('Using default database source');
     }, true);
     $di->set('dbOne', function () {
         require 'unit-tests/config.db.php';
         return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
     }, true);
     $di->set('dbTwo', function () {
         require 'unit-tests/config.db.php';
         return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql);
     }, true);
 }
Esempio n. 22
0
 public function setUp()
 {
     $di = new Phalcon\DI();
     $di->set('url', function () {
         $url = new Phalcon\Mvc\Url();
         $url->setBaseUri('/');
         return $url;
     });
     $this->_response = new Phalcon\Http\Response();
     $this->_response->setDI($di);
 }
Esempio n. 23
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);
 }
 public function testAvailableUniquenessWithDefaultDI()
 {
     $di = new \Phalcon\DI();
     $di->set('db', $this->getDbStub());
     $uniquenessOptions = array('table' => 'users', 'column' => 'login');
     $uniqueness = new Uniqueness($uniquenessOptions);
     $validation = new \Phalcon\Validation();
     $validation->add('login', $uniqueness);
     $messages = $validation->validate(array('login' => 'login_free'));
     $this->assertCount(0, $messages);
 }
Esempio n. 25
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;
 }
Esempio n. 26
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);
 }
Esempio n. 27
-1
 public function testViewOptions()
 {
     $config = array('cache' => array('service' => 'otherCache'));
     $di = new Phalcon\DI();
     $di->set('otherCache', function () {
         $frontend = new Phalcon\Cache\Frontend\Output(array('lifetime' => 60));
         return new Phalcon\Cache\Backend\File($frontend, array('cacheDir' => 'unit-tests/cache/'));
     });
     $view = new Phalcon\Mvc\View($config);
     $view->setDI($di);
     $view->setViewsDir('unit-tests/views/');
     $date = date("r");
     $content = '<html>' . $date . '</html>' . PHP_EOL;
     $view->setVar("date", $date);
     $view->start();
     $view->cache(true);
     $view->render('test8', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), $content);
     $view->reset();
     sleep(1);
     $view->setVar("date", date("r"));
     $view->start();
     $view->cache(true);
     $view->render('test8', 'other');
     $view->finish();
     $this->assertEquals($view->getContent(), $content);
 }
Esempio 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;
 }
Esempio 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();
 }
Esempio 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);
 }