public static function dump($var, $willDie = false) { Debug::dump($var, null, true); if ($willDie) { die; } }
public static function dump($var, $label = null, $echo = true) { $env = getenv('APP_ENV') ?: 'production'; if ($env != 'production') { parent::dump($var, $label, $echo); } }
public function showLatestRegionNeighborhoodBordersAction() { $philadelphiaRegionId = 1; $geoJson = $this->neighborhoodStrengthOfIdentityMapper()->getLatestNeighborhoodBordersByRegionIdAsGeoJson($philadelphiaRegionId); \Zend\Debug\Debug::dump($geoJson); exit; }
public function addAction() { WAuthUtil::whetherLogout($this); $request = $this->getRequest(); $form = new PageForm(); //start if ($request->isPost() && isset($request->getPost()['pcontent'])) { $page = new Page(); $user = new User(); $form->bind($page); $form->setData($request->getPost()); if ($form->isValid()) { $auth = WAuthUtil::get_auth(); $schID = $auth->schoolID; $userID = $auth->userID; $page->setSchID($schID); $user->setUserID($userID); $page->setUser($user); $pageID = $this->getservice()->getNewPageIDandMakedir(); $page->setPageID($pageID); $file = $request->getFiles(); $this->getservice()->savePage($page, $file); // Redirect to list of albums如果想要dump就不要转业 return $this->redirect()->toRoute('page'); } else { $messages = $form->getMessages(); Debug::dump($messages); } } WAuthUtil::addUserpanelToLayout($this, '/add'); return new ViewModel(array('pageform' => $form)); }
public function createAction() { if ($this->getRequest()->isPost()) { $sm = $this->getServiceLocator(); $galaxyService = $sm->get('Galaxy\\Service\\Gateway'); $fleetService = $sm->get('Fleet\\Service\\FleetService'); # get active colony id $colony = $galaxyService->getColony($this->getActive('colony')); \Zend\Debug\Debug::dump($colony); # Flotten nur auf eigenen Kolonien erstellen! if ($this->getRequest()->isPost()) { $form = new \Galaxy\Form\Fleet(); $form->setData($this->getRequest()->getPost()); if ($form->isValid()) { $newEntity = $form->getData(); unset($newEntity['id']); unset($newEntity['submit']); $newEntity['x'] = $colony->getX(); $newEntity['y'] = $colony->getY(); $newEntity['spot'] = $colony->getSpot(); $newEntity['user_id'] = $colony->getUserId(); $fid = $fleetService->saveFleet($newEntity); #$success = true; \Zend\Debug\Debug::dump($fid); } else { \Zend\Debug\Debug::dump($form); } } } $this->redirect()->toUrl('/fleets/'); }
public function initDb() { $configArray = $this->sm->get('config'); $db_name = $configArray['doctrine']['connection']['orm_default']; \Zend\Debug\Debug::dump($db_name); exit; $DEBUG = true; // Retrieve the Doctrine 2 entity manager $em = $this->sm->get('doctrine.entitymanager.orm_default'); // Instantiate the schema tool $tool = new \Doctrine\ORM\Tools\SchemaTool($em); // Retrieve all of the mapping metadata $classes = $em->getMetadataFactory()->getAllMetadata(); if ($DEBUG) { print "dropping schema\n"; } // Delete the existing test database schema $tool->dropSchema($classes); if ($DEBUG) { print "creating schema\n"; } // Create the test database schema $tool->createSchema($classes); if ($DEBUG) { print "schema created\n"; } }
/** * return geojson representation of test points given either * * - neighborhood name and region name */ public function showAction() { $neighborhood_name = $this->getRequestParameter('neighborhood'); $region_name = $this->getRequestParameter('region'); $grid_resolution = $this->getRequestParameter('grid-res'); if (empty($neighborhood_name) or empty($region_name) or empty($grid_resolution)) { die("neighborhood_name,region_name and grid_res must all be defined"); } $neighborhood = $this->m()->neighborhoodMapper()->byName($neighborhood_name, $region_name); if (empty($neighborhood)) { die("no neighborhood found"); } $user_polygons = $this->m()->userPolygonMapper()->byNeighborhood($neighborhood); if (empty($user_polygons)) { die("no user polygons found for neighborhood"); } $timer = \Whathood\Timer::start('api'); $points = $this->m()->testPointMapper()->createByUserPolygons($user_polygons, $grid_resolution); $test_point_ms = $timer->elapsed_milliseconds(); $test_point_count = count($points); $this->logger()->info(sprintf("generated %s test points in %sms; %sms per 1000 points", $test_point_count, $test_point_ms, round($test_point_ms / $test_point_count * 1000, 1))); if (empty($points)) { die("no points returned with grid_resolution {$grid_resolution}"); } $timer = \Whathood\Timer::start('election'); $consensus_col = $this->m()->electionMapper()->buildElectionPointCollection($points); $consensus_seconds = $timer->elapsed_seconds(); $this->logger()->info(sprintf("got consensus in %s seconds; %sms per point", $consensus_seconds, round($consensus_seconds / count($points) * 1000, 2))); $timer = \Whathood\Timer::start('election'); $consensus_col = $this->m()->electionMapper()->buildElectionPointCollection($points); $points = $consensus_col->pointsByNeighborhoodId($neighborhood->getId()); \Zend\Debug\Debug::dump(get_class($points[0])); print Json::encode(\Whathood\Spatial\Util::multiPointToGeoJsonArray(new WhMultiPoint($points))); }
public function __invoke($var, $label = null, $echo = true, $exit = false) { if ($exit) { Debug::dump($var, $label = null, $echo = true); return exit($exit); } return Debug::dump($var, $label = null, $echo = true); }
public function run() { $this->loader->register(); echo "</br>"; printf("Executing Thread with ZF2 Loaded (%s)\n", Debug::getSapi()); echo "<pre>"; print_r($this->loader); echo "</pre>"; }
public function testDebugHaveEscaper() { Debug::setSapi('apache'); $escaper = new Escaper(); Debug::setEscaper($escaper); $a = array("a" => "<script type=\"text/javascript\""); $result = Debug::dump($a, "LABEL", false); $this->assertContains("<script type="text/javascript""", $result); }
/** * @return array|PostInterface[] */ public function findAll() { $sql = new Sql($this->dbAdapter); $select = $sql->select('posts'); $stmt = $sql->prepareStatementForSqlObject($select); $result = $stmt->execute(); // return $result; \Zend\Debug\Debug::dump($result); die; }
/** * @return array|object */ public function getCategories() { $rsm = new ResultSetMapping(); $qb = $this->createQueryBuilder('ca')->select(['ca', 'cc', 'c'])->leftJoin('cats', 'cc', 'ON', 'cc.category_id = ca.id')->leftJoin('content', 'c', 'ON', 'cc.content_id = c.id')->getQuery()->getResult(); // $em = $this->getEntityManager()->createQuery("SELECT * FROM SD\Admin\Entity\Category", $rsm); echo \Zend\Debug\Debug::dump($qb, null, false); exit; $qb = $this->createQueryBuilder('p'); return $this->createQueryBuilder(['ca'])->select('ca')->leftJoin('c')->orderBy('ca.id', 'ASC')->getQuery()->getResult(); }
/** * @group ZF-4136 * @group ZF-1663 */ public function testXdebugEnabledAndNonCliSapiDoesNotEscapeSpecialChars() { if (!extension_loaded('xdebug')) { $this->markTestSkipped("This test only works in combination with xdebug."); } Debug::setSapi('apache'); $a = array("a" => "b"); $result = Debug::dump($a, "LABEL", false); $this->assertContains("<pre>", $result); $this->assertContains("</pre>", $result); }
public function getService() { $dbAdapter = $this->getPluginManager(); //$sm = $this->getServiceLocator(); //$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $viola = $this->getEventManager(); \Zend\Debug\Debug::dump($viola); \Zend\Debug\Debug::dump($dbAdapter); die; return $dbAdapter; }
public function __invoke($arr) { if (is_array($arr)) { \Zend\Debug\Debug::dump($this->getServiceLocator()->getServiceLocator()); echo '<ul>'; foreach ($arr as $v) { echo '<li>' . $v . '</li>'; } echo '</ul>'; } }
public function editAction() { $regionName = $this->getEvent()->getRouteMatch()->getParam('region'); $neighborhoods = $this->neighborhoodMapper()->getAuthoritativeNeghborhoodsByRegionName($regionName); \Zend\Debug\Debug::dump($neighborhoods); exit; $userName = $neighborhoods[0]->getUser()->getName(); $viewModel = new ViewModel(array('neighborhoods' => $neighborhoods, 'regionName' => $regionName, 'userName' => $userName)); $viewModel->setTemplate('whathood/region/region-show.phtml'); return $viewModel; }
/** * Destructor. * * Applies any configured settings such as the maximum string length and * maximum array depth when using `var_dump()`. * * Each of the variables set is then dumped using `var_dump()`, and the * calling file and line are output. * * Any settings are then reverted back to their original values. * * If this object has been configured to exit after dumping, `exit` is * then called. */ public function __destruct() { $this->_applySettings(); foreach ($this->_variables as $var) { ZendDebug::dump($var); } echo sprintf('<p>Dump in <strong>%s</strong>:<strong>%s</strong></p>', $this->_callFile, $this->_callLine); $this->_revertSettings(); if ($this->_quit) { exit; } }
/** * @param array|AclOptions $options * @throws Exception\RuntimeException */ public function setOptions($options) { if ($options instanceof AclOptions) { $this->options = $options; } elseif (is_array($options)) { $this->options = new AclOptions($options); } else { static::$logger->error("Bad options got"); static::$logger->debug(Debug::dump($options, "Bad options got", false)); throw new RuntimeException("Bad options got"); } }
/** * @param array $data * @return mixed|void */ public function login($data) { $username = $this->userMapper->findUsername($data->username); $s = new AuthAdapter($data->username, $data->password); $result = $s->prepareAuth($username['username'], $username['password']); \Zend\Debug\Debug::dump($result); // $result->getCode(); // $ide = $result->getIdentity(); // $vali = $result->isValid(); // \Zend\Debug\Debug::dump($result->getCode()); // \Zend\Debug\Debug::dump($ide); }
public function detailAction() { WAuthUtil::whetherLogout($this); //form $form = new FollowForm(); $id = $this->params()->fromRoute('id'); //增加点击次数 $this->getFollowService()->updateClicktime($id); //查看是否评论,进行request处理 $request = $this->getRequest(); $whetherlogin = false; $userID = 0; $auth = WAuthUtil::get_auth(); $star = null; if ($auth) { $whetherlogin = true; $userID = $auth->userID; $star = $this->getFollowService()->getStar($userID, $id); } if ($request->isPost() && isset($request->getPost()['fcontent'])) { if ($auth) { $followObject = new Follow(); $user = new User(); //!之所以要用一个对象,是因为follow对象里面没有userID这个属性,要在mapper里手工加上 $form->bind($followObject); //通过Hydrator\ArraySerializable 通过model的exchangeArray $form->setData($request->getPost()); if ($form->isValid()) { $user->setUserID($userID); $followObject->setUser($user); $followObject->setPageID($id); $this->getFollowService()->saveFollow($followObject); // Redirect to list of albums如果想要dump就不要转业 // return $this->redirect()->toRoute('page'); } else { $messages = $form->getMessages(); Debug::dump($messages); } } } //读取page信息 try { $page = $this->getPageService()->getPage($id); } catch (\InvalidArgumentException $ex) { return $this->redirect()->toRoute('blog'); } //读取follow信息 $follows = $this->getFollowService()->getFollows($id); // // Debug::dump($page); WAuthUtil::addUserpanelToLayout($this, '/detail/' . $id); return new ViewModel(array('userID' => $userID, 'page' => $page, 'follows' => $follows, 'form' => $form, 'whetherLogin' => $whetherlogin, 'simi' => $this->getFollowService()->getSimi($id), 'star' => $star)); }
public function save(UserEntity $user) { //$this->em->clear(); $this->em->persist($user); $this->em->flush($user); if ($user->getId() == null) { print "why didn't this save?\n"; \Zend\Debug\Debug::dump($user); $obj = $this->em->find("Whathood\\Entity\\WhathoodUser", 1); \Zend\Debug\Debug::dump($obj); exit; } }
public function checkAccess($e) { $route = $e->getRouteMatch(); $session = new Container('user'); $role = isset($session->role) ? $session->role : 'guest'; if (!$this->acl->hasResource($route->getParam('controller'))) { $access = false; } else { $access = $this->acl->isAllowed($role, $route->getParam('controller'), $route->getParam('action')); } Debug::dump($access, 'Assess:'); // if(!$access) { exit('Restricted Access!'); } }
public function factory_ldap(ServiceManager $sm) { $config = $sm->get('Config'); $ldapConfig = $config['ldap']; try { $ldap = new Ldap($ldapConfig); $ldap->bind($ldapConfig['username'], $ldapConfig['password']); } catch (LdapException $e) { Debug::dump($e->getMessage()); die; } return $ldap; }
public function prepareAuthBcrypt($username, $password) { if ($this->username === $username) { $bcrypt = new Bcrypt(); $login = $bcrypt->verify($this->password, $password); var_dump($login); die; if ($login) { $result = $this->authenticate(); return $result; } else { \Zend\Debug\Debug::dump('logowanie nie powiodło się ' . $this->username); } } }
/** * Example of AJAX File Upload with Session Progress. * * @return array|ViewModel */ public function sessionAction() { $form = new Form\ProgressUpload('file-form'); if ($this->getRequest()->isPost()) { // Postback $data = array_merge($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()); $form->setData($data); if ($form->isValid()) { // Get raw file data array $fileData = $form->get('file')->getValue(); Debug::dump($fileData); die; } } return array('form' => $form); }
/** * This method formats the event for the PHP Exception * * @param array $event * @return string */ public function format($event) { $output = $this->format; foreach ($event as $key => $value) { if ('extra' === $key) { $value = Debug::dump($value, $key, false); } else { $value = $this->normalize($value); } $output = str_replace("%{$key}%", $value, $output); } if (isset($event['extra']) && empty($event['extra']) && false !== strpos($this->format, '%extra%')) { $output = rtrim($output, ' '); } return $output; }
public function onBootstrap(\Zend\Mvc\MvcEvent $e) { /* @formatter:off */ /* @var $application \Zend\Mvc\Application */ $application = $e->getApplication(); /* @var $serviceManager \Zend\ServiceManager\ServiceManager */ $serviceManager = $application->getServiceManager(); /* @var $em \Zend\EventManager\EventManager */ $eventManager = $application->getEventManager(); /* @var $sharedManager \Zend\EventManager\SharedEventManager */ $sharedManager = $eventManager->getSharedManager(); /** * These are the event hooks for the Zend\Mvc\Application */ $eventManager->attach(array('route', 'dispatch', 'render', 'finish'), function ($event) { /* @var $event \Zend\Mvc\MvcEvent */ /* @var $target \Zend\Mvc\Application */ /* @var $route \Zend\Mvc\Router\Http\RouteMatch */ $target = $event->getTarget(); \Zend\Debug\Debug::dump(__NAMESPACE__ . ' ' . get_class($target) . ' ' . $event->getName()); // change the template of all the modules // $viewModel = $event->getViewModel(); // $viewModel->setTemplate('layout/error'); //$route = $target->getMvcEvent()->getRouteMatch(); }); /** * These are the event hooks for the Zend\Mvc\Controller\AbstractActionController */ $sharedManager->attach('Zend\\Mvc\\Controller\\AbstractActionController', array('dispatch'), function ($event) { /* @var $event \Zend\Mvc\MvcEvent */ /* @var $target \Zend\Mvc\Controller\AbstractActionController */ $target = $event->getTarget(); \Zend\Debug\Debug::dump(__NAMESPACE__ . ' ' . get_class($target) . ' ' . $event->getName()); //$target->getEvent()->getRouteMatch()->setParam('company_id', 100001); }); /** * These are the event hooks for the Zend\View\View */ $viewManager = $serviceManager->get('ViewManager')->getView()->getEventManager(); $viewManager->attach(array('renderer', 'response'), function ($event) { /* @var $event \Zend\View\ViewEvent */ /* @var $target \Zend\View\View */ $target = $event->getTarget(); \Zend\Debug\Debug::dump(__NAMESPACE__ . ' ' . get_class($target) . ' ' . $event->getName()); }); /* @formatter:on */ }
/** * Example of AJAX File Upload with Session Progress. * * @return array|ViewModel */ public function sessionAction() { $form = new Form\ProgressUpload('file-form'); if ($this->getRequest()->isPost()) { // Postback $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()); $form->setData($data); if ($form->isValid()) { // // ...Save the form... // Debug::dump($form->getData()); die; } else { Debug::dump($form->getMessages()); } } return array('form' => $form); }
public function createAction() { $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $entity = new CrudOtmCollectionUserEntity(); $form = new CrudOtmCollectionCreateForm($objectManager); $form->bind($entity); if ($this->getRequest()->isPost()) { $form->setData($this->getRequest()->getPost()); Debug::dump($this->getRequest()->getPost()); if ($form->isValid()) { $objectManager->persist($entity); $objectManager->flush(); } else { return new ViewModel(array('form' => $form)); } } else { return new ViewModel(array('form' => $form)); } return $this->redirect()->toUrl($this->url()->fromRoute('crud-otm-collection-read')); }
public function detailAction() { WAuthUtil::whetherLogout($this); //form $form = new RFollowForm(); $id = $this->params()->fromRoute('id'); //查看是否评论,进行request处理 $request = $this->getRequest(); if ($request->isPost() && isset($request->getPost()['rfcontent'])) { $followObject = new RFollow(); $user = new User(); //!之所以要用一个对象,是因为follow对象里面没有userID这个属性,要在mapper里手工加上 $form->bind($followObject); //通过Hydrator\ArraySerializable 通过model的exchangeArray $form->setData($request->getPost()); if ($form->isValid()) { $auth = WAuthUtil::get_auth(); $userID = $auth->userID; $user->setUserID($userID); $followObject->setUser($user); $followObject->setRecruitID($id); $this->getRFollowService()->saveRFollow($followObject); // Redirect to list of albums如果想要dump就不要转业 // return $this->redirect()->toRoute('page'); } else { $messages = $form->getMessages(); Debug::dump($messages); } } //读取page信息 try { $recruit = $this->getRecruitService()->getRecruit($id); } catch (\InvalidArgumentException $ex) { return $this->redirect()->toRoute('blog'); } //读取follow信息 $follows = $this->getRFollowService()->getRFollows($id); // // Debug::dump($page); WAuthUtil::addUserpanelToLayout($this, '/detail/' . $id); return new ViewModel(array('recruit' => $recruit, 'follows' => $follows, 'form' => $form)); }