本文整理汇总了PHP中Doctrine\Common\Util\Debug::dump方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::dump方法的具体用法?PHP Debug::dump怎么用?PHP Debug::dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Util\Debug
的用法示例。
在下文中一共展示了Debug::dump方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @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);
}
示例2: execute
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));
}
示例3: listAllByUserAction
/**
* @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);
}
示例4: dump
/**
* 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']) ? '» file : <b>' . $backtrace[0]['file'] . '</b>' . PHP_EOL : '';
$dieMsg .= isset($backtrace[0]['line']) ? '» line : <b>' . $backtrace[0]['line'] . '</b>' . PHP_EOL : '';
$dieMsg .= isset($backtrace[1]['class']) ? '» class : <b>' . $backtrace[1]['class'] . '</b>' . PHP_EOL : '';
$dieMsg .= isset($backtrace[1]['function']) ? '» 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;
}
}
示例5: dump
/**
* {@inheritdoc}
*/
public function dump($input, $name = NULL)
{
if ($name) {
echo $name . ' => ';
}
Debug::dump($input);
}
示例6: dump
/**
* 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;
}
示例7: createAction
/**
* 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()));
}
示例8: nieginie
/**
* 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;
}
}
示例9: execute
/**
* {@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'));
}
示例10: render
/**
* 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);
}
示例11: execute
/**
* @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);
}
}
示例12: dumpd
function dumpd($obj, $exit = 1)
{
echo '<pre>';
\Doctrine\Common\Util\Debug::dump($obj);
if ($exit) {
die;
}
echo "</pre>";
}
示例13: testDisablesOutput
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);
}
示例14: run
/**
* @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);
}
示例15: dumpLevel
public static function dumpLevel($var, $maxDepth = 2)
{
$env = getenv('APP_ENV') ?: 'production';
if ($env != 'production') {
echo '<pre>';
DoctrineDebug::dump($var, $maxDepth);
echo '</pre>';
}
}