Since: 2.0
Author: Guilherme Blanco (guilhermeblanco@hotmail.com)
Author: Jonathan Wage (jonwage@gmail.com)
Author: Roman Borschel (roman@code-factory.org)
Author: Giorgio Sironi (piccoloprincipeazzurro@gmail.com)
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $this->getHelper("app")->getApplication();
     $ns = $app["url_shortener.ns"];
     $link = $app[$ns . 'shortener_service']->shorten($input->getArgument("url"), $input->getOption("custom"));
     $output->writeln(Debug::dump($link));
 }
Ejemplo n.º 2
0
/**
 * Inspiracja: https://www.youtube.com/watch?v=P17pg55FbvA.
 *
 * @param mixed      $data
 * @param string|int $mode
 *                             1: [-012]: (def: 0), -0: ::dump(), 1: var_dump(), 2: print_r()
 *                             2: [01]  : (def: 0), 0: pre, 1: nopre
 * @param int        $maxDepth
 * @param bool       $return   - def: false, czy ma zwrócić wynik zamiast wyprintować na ekran
 *
 * @return string
 */
function nieginie($data, $mode = null, $maxDepth = 2, $return = false, $force = false, $trace = null)
{
    if ($force || isdebug()) {
        $trace or $trace = debug_backtrace();
        $trace = array_shift($trace);
        $return and ob_start();
        if (is_null($mode)) {
            $mode = '00';
        }
        $mode = str_pad($mode, 2, '0');
        if ($mode[1] == 0) {
            echo '<pre>';
        }
        echo $trace['file'] . ':' . $trace['line'] . PHP_EOL;
        $k = $mode[0];
        if (in_array($k, array('-', '0', '1'))) {
            if (in_array($k, array('-', '0')) && class_exists('Doctrine\\Common\\Util\\Debug')) {
                //        echo '--== Uwaga Debug::dump() wycina znaczniki html ==--'.PHP_EOL;
                echo 'Debug::dump()' . PHP_EOL;
                ob_start();
                \Doctrine\Common\Util\Debug::dump($data, $maxDepth, true);
                echo ob_get_clean();
            } else {
                echo 'var_dump()' . PHP_EOL;
                var_dump($data);
            }
        } else {
            echo 'print_r()' . PHP_EOL;
            print_r($data);
        }
        return $return ? ob_get_clean() : null;
    }
}
Ejemplo n.º 3
0
 /**
  * Creates a new Rooms entity.
  *
  */
 public function createAction(Request $request, $hotelId)
 {
     $entity = new Rooms();
     $form = $this->createCreateForm($entity, $hotelId);
     $form->handleRequest($request);
     $em = $this->getDoctrine()->getManager();
     $entitiesHotelSeasons = $em->getRepository('KvartiriBundle:Hotels')->find($hotelId);
     if ($form->isValid()) {
         $hotelSeason = $request->get('hotelseasons');
         $price = $request->get('price');
         /*             * Ma logique pour enregistrer les prix* */
         \Doctrine\Common\Util\Debug::dump($price);
         $index = 0;
         foreach ($hotelSeason as $hotels) {
             $roomSeasons[$hotels] = new RoomSeasons();
             // $rooms = new Rooms();
             $HotelSeasons = $em->getRepository('KvartiriBundle:HotelSeasons')->find($hotels);
             $roomSeasons[$hotels]->setPrice($price[$index]);
             $roomSeasons[$hotels]->addHotelSeason($HotelSeasons);
             $entity->addRoomSeason($roomSeasons[$hotels]);
             //$em->persist($value);
             //   $rooms->getRoomSeasons()->add($HotelSeasons);
             //   \Doctrine\Common\Util\Debug::dump($roomSeasons[0]);
             $index++;
         }
         foreach ($roomSeasons as $value) {
             $em->persist($value);
         }
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('adminRooms_show', array('id' => $entity->getId(), 'hotelId' => $hotelId)));
     }
     return $this->render('KvartiriBundle:Admin:Rooms/new.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'hotelsSeasons' => $entitiesHotelSeasons->getHotelSeasons()));
 }
Ejemplo n.º 4
0
 /**
  * Function that dumps an array or object. It uses the Doctrine dumper so we don't
  * get annoyed by Doctrine objects recursions.
  *
  * @param  $var          mixed   Variable to dump
  * @param  $name         string  Name of the var to dump
  * @param  $die          Boolean Tells the function to stop the process or not
  * @param  $maxDepth     integer Max depth allowed when debugging objects
  * @param  $returnBuffer Boolean Tells if the debug must be returned as a string
  *
  * @return string|null
  */
 public function dump($var, $name = 'var', $die = false, $maxDepth = 2, $returnBuffer = false)
 {
     ob_start();
     echo '<br/><pre>' . $name . (is_object($var) ? ' (' . get_class($var) . ')' : '') . ' :<br/>';
     DoctrineDebug::dump($var, $maxDepth);
     echo '</pre>';
     $buffer = ob_get_contents();
     ob_end_clean();
     $backtrace = debug_backtrace();
     $dieMsg = '<pre><b>Process stopped by "coils.tools.debug" service</b>' . PHP_EOL;
     $dieMsg .= isset($backtrace[0]['file']) ? '&raquo; file     : <b>' . $backtrace[0]['file'] . '</b>' . PHP_EOL : '';
     $dieMsg .= isset($backtrace[0]['line']) ? '&raquo; line     : <b>' . $backtrace[0]['line'] . '</b>' . PHP_EOL : '';
     $dieMsg .= isset($backtrace[1]['class']) ? '&raquo; class    : <b>' . $backtrace[1]['class'] . '</b>' . PHP_EOL : '';
     $dieMsg .= isset($backtrace[1]['function']) ? '&raquo; function : <b>' . $backtrace[1]['function'] . '</b>' . PHP_EOL : '';
     $dieMsg .= '</pre>';
     if ($returnBuffer) {
         return $buffer;
     } else {
         echo $buffer;
     }
     if (true == $die) {
         die($dieMsg);
     } else {
         echo $dieMsg;
     }
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     if (($dql = $input->getArgument('dql')) === null) {
         throw new \RuntimeException("Argument 'DQL' is required in order to execute this command correctly.");
     }
     $depth = $input->getOption('depth');
     if (!is_numeric($depth)) {
         throw new \LogicException("Option 'depth' must contains an integer value");
     }
     $hydrationModeName = $input->getOption('hydrate');
     $hydrationMode = 'Doctrine\\ORM\\Query::HYDRATE_' . strtoupper(str_replace('-', '_', $hydrationModeName));
     if (!defined($hydrationMode)) {
         throw new \RuntimeException("Hydration mode '{$hydrationModeName}' does not exist. It should be either: object. array, scalar or single-scalar.");
     }
     $query = $em->createQuery($dql);
     if (($firstResult = $input->getOption('first-result')) !== null) {
         if (!is_numeric($firstResult)) {
             throw new \LogicException("Option 'first-result' must contains an integer value");
         }
         $query->setFirstResult((int) $firstResult);
     }
     if (($maxResult = $input->getOption('max-result')) !== null) {
         if (!is_numeric($maxResult)) {
             throw new \LogicException("Option 'max-result' must contains an integer value");
         }
         $query->setMaxResults((int) $maxResult);
     }
     $resultSet = $query->execute(array(), constant($hydrationMode));
     Debug::dump($resultSet, $input->getOption('depth'));
 }
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $dm = $this->getDocumentManager();
     $qb = $dm->getRepository($input->getArgument('class'))->createQueryBuilder();
     $qb->setQueryArray((array) json_decode($input->getArgument('query')));
     $qb->hydrate((bool) $input->getOption('hydrate'));
     $depth = $input->getOption('depth');
     if (!is_numeric($depth)) {
         throw new \LogicException("Option 'depth' must contain an integer value");
     }
     if (($skip = $input->getOption('skip')) !== null) {
         if (!is_numeric($skip)) {
             throw new \LogicException("Option 'skip' must contain an integer value");
         }
         $qb->skip((int) $skip);
     }
     if (($limit = $input->getOption('limit')) !== null) {
         if (!is_numeric($limit)) {
             throw new \LogicException("Option 'limit' must contain an integer value");
         }
         $qb->limit((int) $limit);
     }
     foreach ($qb->getQuery() as $result) {
         \Doctrine\Common\Util\Debug::dump($result, $depth);
     }
 }
Ejemplo n.º 7
0
 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $dm = $this->getHelper('dm')->getDocumentManager();
     $query = json_decode($input->getArgument('query'));
     $cursor = $dm->getRepository($input->getArgument('class'))->findBy((array) $query);
     $cursor->hydrate((bool) $input->getOption('hydrate'));
     $depth = $input->getOption('depth');
     if (!is_numeric($depth)) {
         throw new \LogicException("Option 'depth' must contain an integer value");
     }
     if (($skip = $input->getOption('skip')) !== null) {
         if (!is_numeric($skip)) {
             throw new \LogicException("Option 'skip' must contain an integer value");
         }
         $cursor->skip((int) $skip);
     }
     if (($limit = $input->getOption('limit')) !== null) {
         if (!is_numeric($limit)) {
             throw new \LogicException("Option 'limit' must contain an integer value");
         }
         $cursor->limit((int) $limit);
     }
     $resultSet = $cursor->toArray();
     \Doctrine\Common\Util\Debug::dump($resultSet, $depth);
 }
Ejemplo n.º 8
0
 /**
  * Dumps debug data to the debug logger.
  *
  * @param mixed ... $params
  *
  * @return string
  */
 public static function dump(...$params)
 {
     $htmlResult = '';
     $debugFactory = new DebugFactory();
     $logger = $debugFactory->getDebugLogger();
     $handleEnity = function ($value, &$result) {
         ob_start();
         \Doctrine\Common\Util\Debug::dump($value);
         $result .= ob_get_contents();
         ob_end_clean();
     };
     foreach ($params as $value) {
         if ($value === true) {
             $htmlResult .= '{true}';
         } elseif ($value === false) {
             $htmlResult .= '{true}';
         } elseif ($value === null) {
             $htmlResult .= '{null}';
         } elseif ($value instanceof Entity) {
             $handleEnity($value, $htmlResult);
         } elseif (is_array($value) && isset($value[0]) && $value[0] instanceof Entity) {
             foreach ($value as $v) {
                 $handleEnity($v, $htmlResult);
             }
         } else {
             $htmlResult .= print_r($value, true);
         }
     }
     $logger->debug($htmlResult);
     return $htmlResult;
 }
Ejemplo n.º 9
0
 /**
  * A wrapper for var_dump() or Doctrine's Dump Utility.
  *
  * @param string $title optional custom title for the debug output
  * @param integer $maxDepth Sets the max recursion depth of the dump (defaults to 8). De- or increase the number according to your needs and memory limit.
  * @param boolean $plainText If TRUE, the dump is in plain text, if FALSE the debug output is in HTML format.
  * @param boolean $ansiColors If TRUE, ANSI color codes is added to the plaintext output, if FALSE (default) the plaintext debug output not colored.
  * @param boolean $inline if TRUE, the dump is rendered at the position of the <f:debug> tag. If FALSE (default), the dump is displayed at the top of the page.
  * @param array $blacklistedClassNames An array of class names (RegEx) to be filtered. Default is an array of some common class names.
  * @param array $blacklistedPropertyNames An array of property names and/or array keys (RegEx) to be filtered. Default is an array of some common property names.
  * @return string
  */
 public function render($title = NULL, $maxDepth = 8, $plainText = FALSE, $ansiColors = FALSE, $inline = FALSE, $blacklistedClassNames = NULL, $blacklistedPropertyNames = NULL)
 {
     if (class_exists('Doctrine\\Common\\Util\\Debug')) {
         return \Doctrine\Common\Util\Debug::dump($this->renderChildren(), $maxDepth, !$plainText);
     }
     return var_export($this->renderChildren(), TRUE);
 }
Ejemplo n.º 10
0
 /**
  * @Route("/listby", name="listby")
  */
 public function listAllByUserAction(Request $request)
 {
     $loggedInUser = $this->getUser();
     $em = $this->getDoctrine()->getEntityManager();
     $jobsOrderedByTitle = $em->getRepository('AppBundle:Job')->findAllByUser($loggedInUser);
     Debug::dump($jobsOrderedByTitle);
 }
Ejemplo n.º 11
0
function dumpd($obj, $exit = 1)
{
    echo '<pre>';
    \Doctrine\Common\Util\Debug::dump($obj);
    if ($exit) {
        die;
    }
    echo "</pre>";
}
Ejemplo n.º 12
0
 public function testDisablesOutput()
 {
     ob_start();
     $dump = Debug::dump('foo', 2, true, false);
     $outputValue = ob_get_contents();
     ob_end_clean();
     $this->assertEmpty($outputValue);
     $this->assertNotSame($outputValue, $dump);
 }
Ejemplo n.º 13
0
 public function testExportArrayTraversable()
 {
     $obj = new \ArrayObject(array('foobar'));
     $var = Debug::export($obj, 2);
     $this->assertContains('foobar', $var->__STORAGE__);
     $it = new \ArrayIterator(array('foobar'));
     $var = Debug::export($it, 5);
     $this->assertContains('foobar', $var->__STORAGE__);
 }
Ejemplo n.º 14
0
 public static function dumpLevel($var, $maxDepth = 2)
 {
     $env = getenv('APP_ENV') ?: 'production';
     if ($env != 'production') {
         echo '<pre>';
         DoctrineDebug::dump($var, $maxDepth);
         echo '</pre>';
     }
 }
Ejemplo n.º 15
0
 /**
  * @Route("Amis/test",name="test")
  * @Template("AppBundle:Amis:emailconfirmation.html.twig")
  */
 public function TestAction()
 {
     $criteria = array('friends' => $this->getUser()->getId(), 'confirmation' => 1);
     $amis = $this->getDoctrine()->getManager()->getRepository('AppBundle:Friend')->findBy($criteria);
     $criteriaconf = array('friends' => $this->getUser()->getId(), 'confirmation' => 0, 'demande' => 0);
     $amisconfirmation = $this->getDoctrine()->getManager()->getRepository('AppBundle:Friend')->findOneBy($criteria);
     \Doctrine\Common\Util\Debug::dump($amisconfirmation);
     return array('User' => $this->getUser());
 }
Ejemplo n.º 16
0
 public static function dump($entity, $maxDepth = 1, $toHtml = true)
 {
     $output = print_r(Debug::export($entity, $maxDepth), true);
     if ($toHtml) {
         echo "<pre>{$output}</pre>";
     } else {
         echo $output;
     }
 }
Ejemplo n.º 17
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $arguments = $this->getArguments();
     $em = $this->getConfiguration()->getAttribute('em');
     $query = $em->createQuery($arguments['dql']);
     $resultSet = $query->getResult();
     $maxDepth = isset($arguments['depth']) ? $arguments['depth'] : 7;
     Debug::dump($resultSet, $maxDepth);
 }
Ejemplo n.º 18
0
 public static function dump($var, $maxDepth = 2, $stripTags = true)
 {
     ob_start();
     DoctrineDebug::dump($var, $maxDepth, $stripTags);
     $dump = ob_get_clean();
     echo '<pre>';
     echo $dump;
     echo '</pre>';
 }
Ejemplo n.º 19
0
 public function bootstrapGlobalMvcEventErrorListener(MvcEvent $event)
 {
     $eventManager = $event->getApplication()->getEventManager();
     $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $event) {
         $exception = $event->getParam('exception');
         if (isset($exception)) {
             Debug::dump($exception, 10);
         }
     }, 100);
 }
Ejemplo n.º 20
0
 /**
  * execute un var_dump with <pre> tag
  * @param type $param
  * @param type $die
  * @return type
  */
 public static function dump($param, $die = true)
 {
     echo '<pre>';
     Debug::dump($param);
     echo '</pre>';
     if ($die) {
         die;
     }
     return;
 }
Ejemplo n.º 21
0
 public function onMessageConsumptionFailed(MessageConsumptionFailedEvent $event)
 {
     /// @todo this might give php warnings
     ///       We could also check if Symfony\Component\VarDumper is available and use it instead...
     if (class_exists('Doctrine\\Common\\Util\\Debug')) {
         echo "Message failed consumption at " . strftime('%Y/%m/%d - %H:%M:%S', time()) . ": " . \Doctrine\Common\Util\Debug::dump($event->getException(), 2, false, false) . "\n";
     } else {
         echo "Message failed consumption at " . strftime('%Y/%m/%d - %H:%M:%S', time()) . ": " . var_export($event->getException(), true) . "\n";
     }
 }
Ejemplo n.º 22
0
 /**
  * {@inheritdoc}
  */
 protected function convertToString($data)
 {
     if (null === $data || is_bool($data)) {
         return var_export($data, true);
     }
     if (is_scalar($data)) {
         return (string) $data;
     }
     return Debug::dump($data, 2, true, false);
 }
 /**
  * {@inheritdoc}
  */
 public function export($input, $name = NULL)
 {
     $name = $name ? $name . ' => ' : '';
     $variable = Debug::export($input, 6);
     ob_start();
     print_r($variable);
     $dump = ob_get_contents();
     ob_end_clean();
     $dump = '<pre>' . $name . $dump . '</pre>';
     return $this->setSafeMarkup($dump);
 }
Ejemplo n.º 24
0
 /**
  * Debug pretty printer
  *
  * @param $var
  * @param bool $echo
  * @return string
  */
 public static function dump($var, $echo = true, $pre = true)
 {
     ob_start();
     \Doctrine\Common\Util\Debug::dump($var);
     $dump = ob_get_clean();
     $output = $pre === true ? sprintf('<pre>%s</pre>', $dump) : $dump;
     if ($echo === true) {
         echo $output;
     }
     return $output;
 }
Ejemplo n.º 25
0
 /**
  *
  * @param \Sb\Db\Model\Invitation $Invitation
  */
 public function add(\Sb\Db\Model\Invitation $invitation)
 {
     \Doctrine\Common\Util\Debug::dump($invitation);
     \Doctrine\Common\Util\Debug::dump($invitation->getGuest());
     if ($invitation->getGuest()) {
         $this->entityManager->persist($invitation->getGuest());
     }
     $this->entityManager->persist($invitation);
     $this->entityManager->flush();
     return true;
 }
 public function regAction()
 {
     $category = 'Most Popular';
     $repository = $this->getDoctrine()->getRepository('AcmeDemoBundle:Rodzice');
     // $movie = $repository->findImie(6.99);
     // $repository = $this->getDoctrine()->getRepository('BmwMainBundle:Review');
     $stmt = $this->getDoctrine()->getManager()->getConnection()->prepare('SELECT * FROM rodzice');
     $stmt->execute();
     $mostPopular = $stmt->fetchAll();
     exit(\Doctrine\Common\Util\Debug::dump($mostPopular));
     return new Response('<html><body>Hello ' . "" . '!</body></html>');
 }
Ejemplo n.º 27
0
 public function SupprimerFriend()
 {
     $id = $this->request->getCurrentRequest()->get('id');
     $friend = $this->em->getRepository('AppBundle:User')->find($id);
     $criteria = array('user' => $friend, 'friends' => $this->user);
     $criteria2 = array('user' => $this->user, 'friends' => $friend);
     $Friends = $this->em->getRepository('AppBundle:Friend')->findOneBy($criteria);
     $Friends1 = $this->em->getRepository('AppBundle:Friend')->findOneBy($criteria2);
     \Doctrine\Common\Util\Debug::dump($Friends1);
     $this->em->remove($Friends);
     $this->em->remove($Friends1);
     $this->em->flush();
 }
 public function sipPeersAction()
 {
     $this->asteriskService = $this->get('TMSolution.AsteriskBundle.AsteriskService');
     $this->asteriskConnection = $this->asteriskService->connect('192.168.2.55', 'nexuscc', 'gerthruda');
     //$event = new AsteriskEvent($this);
     $this->asteriskService->addListener('peerentry', function ($event, $eventName) {
         //var_dump($event);
         echo '<pre>';
         \Doctrine\Common\Util\Debug::dump($var);
         echo '</pre>';
     });
     $sipPeers = $this->asteriskService->cmdSipPeers();
     return new Response('ok');
 }
Ejemplo n.º 29
0
 public function index(Application $app, Request $request, $page_no = null)
 {
     $session = $request->getSession();
     $pagination = array();
     $searchForm = $app['form.factory']->createBuilder('admin_search_customer')->getForm();
     $pageMaxis = $app['eccube.repository.master.page_max']->findAll();
     $page_count = $app['config']['default_page_count'];
     if ('POST' === $request->getMethod()) {
         $searchForm->handleRequest($request);
         if ($searchForm->isValid()) {
             $searchData = $searchForm->getData();
             // paginator
             $qb = $app['eccube.repository.customer']->getQueryBuilderBySearchData($searchData);
             $page_no = 1;
             $pagination = $app['paginator']()->paginate($qb, $page_no, $page_count);
             // sessionのデータ保持
             $session->set('eccube.admin.customer.search', $searchData);
         }
     } else {
         if (is_null($page_no)) {
             // sessionを削除
             $session->remove('eccube.admin.customer.search');
         } else {
             // pagingなどの処理
             $searchData = $session->get('eccube.admin.customer.search');
             if (!is_null($searchData)) {
                 // 表示件数
                 $pcount = $request->get('page_count');
                 $page_count = empty($pcount) ? $page_count : $pcount;
                 $qb = $app['eccube.repository.customer']->getQueryBuilderBySearchData($searchData);
                 $pagination = $app['paginator']()->paginate($qb, $page_no, $page_count);
                 // セッションから検索条件を復元
                 if (count($searchData['sex']) > 0) {
                     $sex_ids = array();
                     foreach ($searchData['sex'] as $Sex) {
                         $sex_ids[] = $Sex->getId();
                     }
                     $searchData['sex'] = $app['eccube.repository.master.sex']->findBy(array('id' => $sex_ids));
                 }
                 if (!is_null($searchData['pref'])) {
                     $searchData['pref'] = $app['eccube.repository.master.pref']->find($searchData['pref']->getId());
                     \Doctrine\Common\Util\Debug::dump($searchData['pref']);
                 }
                 $searchForm->setData($searchData);
             }
         }
     }
     return $app->renderView('Customer/index.twig', array('searchForm' => $searchForm->createView(), 'pagination' => $pagination, 'pageMaxis' => $pageMaxis, 'page_no' => $page_no, 'page_count' => $page_count));
 }
Ejemplo n.º 30
0
 public function indexAction()
 {
     $user = new \Emicro\Bundles\CoreBundle\Entity\User();
     $user->setEmail('*****@*****.**');
     $user->setPassword(sha1('123456'));
     $user->setFirstName('Test');
     $user->setLastName('User');
     $user->setCreateDate(new \DateTime());
     $user->setUpdateDate(new \DateTime());
     $em = $this->getDoctrine()->getEntityManager();
     $em->persist($user);
     $em->flush();
     \Doctrine\Common\Util\Debug::dump($user);
     die;
 }