Ejemplo n.º 1
0
 /**
  * Executes the command.
  *
  * @param InputInterface  $input  The input
  * @param OutputInterface $output The output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $class = $input->getArgument('class');
     if (class_exists($class)) {
         $obj = new $class();
         // configure ladybug
         if ($input->getOption('all')) {
             ladybug_set('object.show_data', true);
             ladybug_set('object.show_classinfo', true);
             ladybug_set('object.show_constants', true);
             ladybug_set('object.show_methods', true);
             ladybug_set('object.show_properties', true);
         } else {
             ladybug_set('object.show_data', true);
             ladybug_set('object.show_classinfo', false);
             ladybug_set('object.show_constants', false);
             ladybug_set('object.show_methods', true);
             ladybug_set('object.show_properties', true);
         }
         ladybug_set('object.max_nesting_level', 2);
         ladybug_dump($obj);
     } else {
         $lines = array('[Invalid Class]', 'Class "' . $class . '" not found. ');
         $this->addMessage($output, $lines, 'error');
     }
 }
Ejemplo n.º 2
0
/**
 * Newscoop dump modifier plugin
 *
 * Type:     modifier
 * Name:     dump
 * Purpose:  Dump given object
 *
 * @param Object to dump
 *     $object
 */
function smarty_modifier_dump($object)
{
    if (function_exists('ladybug_dump')) {
        ladybug_dump($object);
    } else {
        print_r($object);
    }
}
 /**
  * Dump
  *
  * @param mixed $thing to be dumped
  * @param int   $i     the index in the stack trace to report as here-ish
  */
 function d($thing, $i = 0)
 {
     $trace = debug_backtrace();
     $lines = array();
     for ($j = $i; $j <= $i + 1; $j++) {
         if (isset($trace[$j]['line'])) {
             $lines[] = "Line <b>{$trace[$j]['line']}</b> of <b>{$trace[$j]['file']}</b>";
         }
     }
     if (PHP_SAPI == 'cli') {
         echo "\n==============================";
     } else {
         echo '</script></style><div style="border: 2px solid red; background-color: white; padding: 5px">';
     }
     $count = 1;
     foreach ($lines as $index => $line) {
         if ($count > 1) {
             $line = "    {$line}";
         }
         if (PHP_SAPI == 'cli') {
             echo "\n{$line}";
         } else {
             if ($count > 1) {
                 $line = "&nbsp;&nbsp;&nbsp;{$line}";
             }
             echo "<pre>{$line}</pre>";
         }
         $count++;
     }
     if (PHP_SAPI == 'cli') {
         echo "\n==============================\n";
     }
     if (function_exists('ladybug_dump')) {
         ladybug_dump($thing);
     } else {
         if (extension_loaded('xdebug')) {
             var_dump($thing);
         } else {
             echo '<pre>';
             var_dump($thing);
             echo '</pre>';
         }
     }
     if (PHP_SAPI == 'cli') {
         echo "\n\n";
     } else {
         echo '</div><br>';
     }
 }
 public function indexAction()
 {
     $elm = new Element('name', 'id');
     // $entries = $elements = $endings = $connections =array();
     // $newChart = new Flowchart('my new chart', $entries, $elements, $endings, $connections);
     // ladybug_dump($newChart);
     $node1 = new Node('my node 1', 'node1');
     $node2 = new Node('my node 2', 'node2');
     $ending1 = new Ending('my ending 1', 'ending1');
     $ending2 = new Ending('my ending 2', 'ending2');
     $entry1 = new Entry('my entry 1', 'entry1');
     $entry2 = new Entry('my entry 2', 'entry2');
     $elements = array($node1, $node2, $ending1, $ending2, $entry1, $entry2);
     $connections = array();
     $newChart = new Flowchart('my new chart', $elements, $connections);
     ladybug_dump($newChart->getElements());
     $entry3 = new Entry('my entry 3', 'entry3');
     $newChart->removeElement($entry3);
     ladybug_dump($newChart->getElements());
     return $this->render('JucevejuFlowchartBundle:Default:index.html.twig', array('jsplumb_path' => $this->container->getParameter('juceveju_flowchart.jsplumb_path')));
 }
Ejemplo n.º 5
0
 /**
  * @Route("/loginuser", name="json_loginuser")
  */
 public function LoginUser()
 {
     ladybug_dump($this->getLoginUser());
 }
Ejemplo n.º 6
0
 function debug()
 {
     ladybug_dump(\Fw\Bundler::$stack);
 }
Ejemplo n.º 7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $since = $input->getOption('since');
         $dry_run = $input->getOption('dry-run');
         $paymentID = $input->getOption('payment-id');
         $max = (int) $input->getOption('max');
         $MAX = 20;
         if ($max > 0 && $max < $MAX) {
             // nada
         } else {
             $max = $MAX;
         }
         $clauses[] = 'p.deferralTimestamp IS NULL';
         $params = array();
         if ($since) {
             $clauses[] = 'p.payment_date > :since';
             $params[':since'] = $since;
         }
         if ($paymentID) {
             $clauses[] = 'p.id = :id';
             $params[':id'] = $paymentID;
         }
         $em = $this->getContainer()->get('doctrine')->getManager();
         $query = $em->createQuery('SELECT p from TSK\\PaymentBundle\\Entity\\Payment p WHERE ' . join(' AND ', $clauses));
         $query->setParameters($params);
         $query->setFirstResult(0);
         $query->setMaxResults($max);
         $payments = $query->getResult();
         if (count($payments)) {
             foreach ($payments as $payment) {
                 $appliedCharges = $payment->getChargePayments();
                 if ($appliedCharges->count()) {
                     foreach ($appliedCharges as $chargePayment) {
                         $charge = $chargePayment->getCharge();
                         // Is this charge of type tuition?  We only defer
                         // the portion of the payment applied to tuition
                         if ($charge->getAccount()->getName() == 'Inc Fm Students') {
                             // get contract details
                             $contracts = $charge->getContracts();
                             $contract = $contracts[0];
                             $contractAmount = $contract->getAmount();
                             $contractStartDate = $contract->getCreatedDate()->format('YYYY-mm-dd');
                             $deferralDuration = $contract->getDeferralDurationMonths();
                             $deferralDistributionStrategy = $contract->getDeferralDistributionStrategy();
                             $deferralDistributionStrategy = 'accelerated';
                             if (!in_array($deferralDistributionStrategy, array('straight', 'accelerated'))) {
                                 throw new \Exception('Unrecognized deferral distribution strategy ' . $deferralDistributionStrategy);
                             }
                             $deferralRate = $contract->getDeferralRate();
                             // Sum any REALIZED payments for this contract and group by year-month ...
                             // Sum any pre-existing deferral payments for this contract and group by year-month
                             // Could have done this in mysql w/ the following query, but Doctrine doesn't support it.
                             // select year(date_realized), month(date_realized), sum(amount) from tsk_payments_deferred where fk_contract_id=6 group by year(date_realized), month(date_realized) order by year(date_realized) asc, month(date_realized) asc
                             $query = $em->createQuery('SELECT p from TSK\\PaymentBundle\\Entity\\PaymentsDeferred p WHERE p.contract=:contract ORDER BY p.dateRealized');
                             $query->setParameters(array(':contract' => $contract));
                             $deferments = $query->getResult();
                             $initialDeferrals = array();
                             foreach ($deferments as $deferment) {
                                 $key = $deferment->getDateRealized()->format('Y-m');
                                 if (empty($initialDeferrals[$key])) {
                                     $initialDeferrals[$key] = $deferment->getAmount();
                                 } else {
                                     $initialDeferrals[$key] += $deferment->getAmount();
                                 }
                             }
                             $inits = array_values($initialDeferrals);
                             if (!$inits) {
                                 $inits = array_fill(0, $contract->getDeferralDurationMonths(), 0);
                             }
                             // Set deferral schedule
                             $d = new Deferral($contract->getAmount(), $contract->getDeferralRate(), $contract->getDeferralDurationMonths(), $inits, $contract->getContractStartDate());
                             // RUN THE DEFERRALS!!
                             $deferralMethod = $deferralDistributionStrategy == 'straight' ? 'distributePaymentEvenly' : 'distributePaymentMax';
                             $deferrals = $d->{$deferralMethod}($chargePayment->getAmount(), $contract->getRemainingDeferralPeriods());
                             $Deferrals = $d->datestampPayments($deferrals);
                             if ($dry_run) {
                                 print "schedule =\n";
                                 ladybug_dump($d->getSchedule());
                                 print "initial deferrals\n";
                                 ladybug_dump($inits);
                                 print "deferrals\n";
                                 $summary = sprintf('<options=bold>$%5.2f</options=bold> Deferred at <options=bold>%3.2f</options=bold> over <options=bold>%d</options=bold> months using <options=bold>"%s"</options=bold> Strategy starting on <options=bold>%s</options=bold>', $chargePayment->getAmount(), $contract->getDeferralRate(), $contract->getRemainingDeferralPeriods(), $contract->getDeferralDistributionStrategy(), $contract->getContractStartDate()->format('Y-m-d'));
                                 $formatter = $this->getHelperSet()->get('formatter');
                                 $formattedLine = $formatter->formatSection('Deferral Summary', $summary);
                                 $output->writeln($formattedLine);
                                 ladybug_dump($Deferrals);
                                 print count($Deferrals) . " payments totalling ";
                                 print array_sum(array_values($Deferrals)) . "\n";
                             } else {
                                 foreach ($Deferrals as $DeferralDate => $DeferralAmount) {
                                     if ($DeferralAmount) {
                                         $paymentDeferred = new PaymentsDeferred();
                                         $paymentDeferred->setPayment($payment);
                                         $paymentDeferred->setAmount($DeferralAmount);
                                         $paymentDeferred->setDateRealized(new \DateTime($DeferralDate));
                                         $paymentDeferred->setContract($contract);
                                         $em->persist($paymentDeferred);
                                     }
                                     // we actually save the deferred payment each time ...
                                     $em->flush();
                                 }
                             }
                         }
                     }
                     if (!$dry_run) {
                         // Update payment deferralTimestamp
                         $payment->setDeferralTimestamp(new \DateTime());
                         $em->persist($payment);
                         $em->flush();
                     }
                 } else {
                     throw new \Exception('No charges applied to payment.  Surely, this cannot be true');
                 }
             }
         } else {
             $dialog = $this->getDialogHelper();
             $dialog->writeSection($output, "No deferrable payments match your criteria, nothing to defer.", 'bg=red;fg=white');
         }
     } catch (\PDOException $e) {
     } catch (\Exception $e) {
         $dialog = $this->getDialogHelper();
         $dialog->writeSection($output, $e->getMessage(), 'bg=red;fg=white');
     }
     if (!empty($results['errors'])) {
         $dialog = $this->getDialogHelper();
         $dialog->writeSection($output, $results['errors'][0], 'bg=yellow;fg=white');
     }
 }
Ejemplo n.º 8
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$connection = mysql_connect('localhost', 'root', '123456');
mysql_select_db('books', $connection);
$result = mysql_query('SELECT id, title, isbn FROM Book', $connection);
ladybug_dump($connection, $result);
Ejemplo n.º 9
0
 /**
  * @Route("/debug", name="debug")
  * @Template
  */
 public function debugAction(Request $request)
 {
     ladybug_dump($this->getSubscriberRepository()->find('55c94bc55c652c8')->getInvoices()->toArray());
     ladybug_dump($this->getChannelRepository()->find('hogehoge'));
 }
Ejemplo n.º 10
0
/**
 * Newscoop dump modifier plugin
 *
 * Type:     modifier
 * Name:     dump
 * Purpose:  Dump given object
 *
 * @param Object to dump
 *     $object
 */
function smarty_modifier_dump($object)
{
    ladybug_dump($object);
}
Ejemplo n.º 11
0
function ladybug_dump_ext()
{
    $params = get_loaded_extensions();
    ladybug_dump($params);
}