本文整理汇总了PHP中AppKernel::getStaticContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP AppKernel::getStaticContainer方法的具体用法?PHP AppKernel::getStaticContainer怎么用?PHP AppKernel::getStaticContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKernel
的用法示例。
在下文中一共展示了AppKernel::getStaticContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->container = $this->getContainer();
$this->em = $this->getContainer()->get('doctrine')->getManager();
//$this->em->getConnection()->getConfiguration()->setSQLLogger(null);
$this->formCSRF = $this->container->get('form.csrf_provider');
$this->adminPool = $this->container->get('sonata.admin.pool');
$this->user = $this->em->getRepository('ApplicationSonataUserBundle:User')->findOneBy(array('id' => $input->getArgument('user_id')));
$this->translator = \AppKernel::getStaticContainer()->get('translator');
$token = new UsernamePasswordToken($this->user, $this->user->getPassword(), "public", $this->user->getRoles());
$this->getContainer()->get("security.context")->setToken($token);
// Fire the login event
$event = new InteractiveLoginEvent($this->getContainer()->get('request'), $token);
$this->getContainer()->get("event_dispatcher")->dispatch("security.interactive_login", $event);
$this->targetProcess = $input->getArgument('target');
$this->user_id = $input->getArgument('user_id');
$this->pid = $input->getArgument('pid');
$file = $input->getArgument('file');
$objReader = \PHPExcel_IOFactory::createReaderForFile($file);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($file);
$sheet = $objPHPExcel->getSheet(0);
$rows = $sheet->toArray();
$this->processClient($rows);
$this->messages = $this->getCountMessageImports();
$this->sendNotification();
echo serialize(array('messages' => $this->messages, 'import_counts' => $this->_import_counts, 'pid' => $this->pid, 'absErrorLogFilename' => $this->absErrorLogFilename));
}
示例2: createQueryBuilder
/**
* {@inheritdoc}
*/
public function createQueryBuilder($alias)
{
$queryBuilder = parent::createQueryBuilder($alias);
/* @var $securityContext SecurityContext */
$securityContext = \AppKernel::getStaticContainer()->get('security.context');
if (!$securityContext->isGranted('ROLE_SUPER_ADMIN')) {
$queryBuilder->where($alias . '.id != :admin_id')->setParameter(':admin_id', 1);
}
return $queryBuilder;
}
示例3: createQueryBuilder
/**
* {@inheritdoc}
*/
public function createQueryBuilder($alias)
{
$queryBuilder = parent::createQueryBuilder($alias);
/* @var $securityContext SecurityContext */
$securityContext = \AppKernel::getStaticContainer()->get('security.context');
if (!$securityContext->isGranted('ROLE_EDIT_ALL_CLIENTS')) {
$queryBuilder->where($alias . '.user = :user')->setParameter(':user', $securityContext->getToken()->getUser());
}
return $queryBuilder;
}
示例4: getDefault
/**
* @return ListDevises
*/
public static function getDefault()
{
if (is_null(static::$default)) {
/* @var $doctrine \Doctrine\Bundle\DoctrineBundle\Registry */
$doctrine = \AppKernel::getStaticContainer()->get('doctrine');
/* @var $em \Doctrine\ORM\EntityManager */
$em = $doctrine->getManager();
static::$default = $em->getRepository('ApplicationSonataClientBundle:ListDevises')->findOneByAlias(static::Device);
}
return static::$default;
}
示例5: __construct
public function __construct()
{
parent::__construct();
/* @var $doctrine \Doctrine\Bundle\DoctrineBundle\Registry */
$doctrine = \AppKernel::getStaticContainer()->get('doctrine');
/* @var $em \Doctrine\ORM\EntityManager */
$em = $doctrine->getManager();
$this->setEnabled(true);
$group = $em->getRepository('ApplicationSonataUserBundle:Group')->find(static::GroupId);
if ($group) {
$this->addGroup($group);
}
}
示例6: __construct
public function __construct($client, $show_all_operations, $year, $month, $excel = null)
{
if (is_null($excel)) {
$this->_excel = new \PHPExcel();
} else {
$this->_excel = $excel;
}
$this->translator = \AppKernel::getStaticContainer()->get('translator');
$this->_client = $client;
$this->_show_all_operations = $show_all_operations;
$this->_year = $year;
$this->_month = $month;
$this->clientDeclaration = new ClientDeclaration($this->_client);
$this->clientDeclaration->setShowAllOperations($this->_show_all_operations)->setYear($this->_year)->setMonth($this->_month);
}
示例7: indexAction
/**
* @Template()
*/
public function indexAction()
{
/** @var $em \Doctrine\ORM\EntityManager */
$em = $this->getDoctrine()->getManager();
$clients = $em->getRepository('ApplicationSonataClientBundle:Client')->createQueryBuilder('c')->select('c, cdi, u, ndc, SUM(cc.montant) as compte_solde_montant, 0 as dimmed')->leftJoin('c.center_des_impots', 'cdi')->leftJoin('c.user', 'u')->leftJoin('c.nature_du_client', 'ndc')->leftJoin('c.comptes', 'cc')->andWhere('(NOT c.date_fin_mission BETWEEN :date_lowest AND :date_highest) OR (c.date_fin_mission IS NULL)')->setParameter(':date_lowest', new \DateTime('1000-01-01'))->setParameter(':date_highest', new \DateTime())->groupBy('c.id')->orderBy('c.raison_sociale')->getQuery()->execute();
$clientsDimmed = $em->getRepository('ApplicationSonataClientBundle:Client')->createQueryBuilder('c')->select('c, cdi, u, ndc, SUM(cc.montant) as compte_solde_montant, 1 as dimmed')->leftJoin('c.center_des_impots', 'cdi')->leftJoin('c.user', 'u')->leftJoin('c.nature_du_client', 'ndc')->leftJoin('c.comptes', 'cc')->andWhere('c.date_fin_mission BETWEEN :date_lowest AND :date_highest')->setParameter(':date_lowest', new \DateTime('1000-01-01'))->setParameter(':date_highest', new \DateTime())->groupBy('c.id')->orderBy('c.raison_sociale')->getQuery()->execute();
$alerts = $em->getRepository('ApplicationSonataClientBundle:Client')->createQueryBuilder('c')->select('SUM(c.alert_count) as cnt')->getQuery()->execute();
$now = new \DateTime();
/*
*
We should have "Mois TVA (M-1).YYYY" if days <= 25
"Mois TVA (M).YYYY" if days > 25
*/
$moisExtraColTitle = $now->format('d') > 25 ? date('m.Y', strtotime('now')) : date('m.Y', strtotime('now -1 month'));
$user = \AppKernel::getStaticContainer()->get('security.context')->getToken()->getUser();
return array('clients' => array_merge($clients, $clientsDimmed), 'cookies' => $this->getRequest()->cookies, 'alert_count' => $alerts[0]['cnt'], 'moisExtraColTitle' => $moisExtraColTitle, 'isSuperviseur' => $user->hasGroup('Superviseur'));
}
示例8: listAction
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function listAction()
{
$user = \AppKernel::getStaticContainer()->get('security.context')->getToken()->getUser();
$this->jsSettingsJson(array('isSuperviseur' => $user->hasGroup('Superviseur')));
global $clientsDimmed;
/** @var $em \Doctrine\ORM\EntityManager */
$em = $this->getDoctrine()->getManager();
$clientsDimmed = json_encode($em->getRepository('ApplicationSonataClientBundle:Client')->createQueryBuilder('c')->select('c as client, cdi, u, ndc, SUM(cc.montant) as compte_solde_montant')->leftJoin('c.center_des_impots', 'cdi')->leftJoin('c.user', 'u')->leftJoin('c.nature_du_client', 'ndc')->leftJoin('c.comptes', 'cc')->andWhere('c.date_fin_mission BETWEEN :date_lowest AND :date_highest')->setParameter(':date_lowest', new \DateTime('1000-01-01'))->setParameter(':date_highest', new \DateTime())->groupBy('c.id')->orderBy('c.raison_sociale')->getQuery()->getArrayResult(), 256);
//return parent::listAction();
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
$datagrid = $this->admin->getDatagrid();
$formView = $datagrid->getForm()->createView();
// set the theme for the current Admin Form
$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
return $this->render($this->admin->getTemplate('list'), array('action' => 'list', 'form' => $formView, 'datagrid' => $datagrid, 'js_settings_json' => $this->_jsSettingsJson));
}
示例9: makeExportData
/**
* @return array
*/
protected function makeExportData()
{
$rows = array();
$rows[] = $this->excelHeader();
/** @var $em \Doctrine\ORM\EntityManager */
$em = \AppKernel::getStaticContainer()->get('doctrine');
/** @var $query \Doctrine\ORM\QueryBuilder */
$object = $em->getRepository('ApplicationSonataClientBundle:Garantie')->createQueryBuilder('g')->orderBy('g.date_decheance', 'ASC')->getQuery()->execute();
$nom_de_la_banques = Garantie::getNomDeLaBanques();
foreach ($object as $key => $row) {
$date_decheance = $row->getDateDecheance() ? \PHPExcel_Shared_Date::PHPToExcel($row->getDateDecheance()) : '';
/** @var $row Garantie */
$cell = array('client' => (string) $row->getClient(), 'date_decheance' => $date_decheance, 'montant' => $row->getMontant(), 'nom_de_la_banques_id' => isset($nom_de_la_banques[$row->getNomDeLaBanquesId()]) ? $nom_de_la_banques[$row->getNomDeLaBanquesId()] : '', 'num_de_ganrantie' => $row->getNumDeGanrantie(), 'note' => $row->getNote(), 'client_date_fin_mission' => $row->getClient()->getDateFinMission() ? \PHPExcel_Shared_Date::PHPToExcel($row->getClient()->getDateFinMission()) : '', 'calc_day_date_decheance' => $date_decheance ? '=B' . ($key + 2) . '-TODAY()' : '');
//format
$this->excelCellFormat($key + 2, $row);
$rows[] = $cell;
}
return $rows;
}
示例10: getStatus
/**
* Get status
*
* @return ListStatuses
*/
public function getStatus()
{
if (!$this->status) {
/* @var $doctrine \Doctrine\Bundle\DoctrineBundle\Registry */
$doctrine = \AppKernel::getStaticContainer()->get('doctrine');
/* @var $em \Doctrine\ORM\EntityManager */
$em = $doctrine->getManager();
$this->setStatus($em->getRepository('ApplicationSonataClientOperationsBundle:ListStatuses')->find(2));
}
return $this->status;
}
示例11: getCurrentDevises
/**
* @param $value
* @return mixed
*/
public function getCurrentDevises($value)
{
$date = new \DateTime($value . '-01');
$doctrine = \AppKernel::getStaticContainer()->get('doctrine');
/* @var $em \Doctrine\ORM\EntityManager */
$em = $doctrine->getManager();
return $em->getRepository('ApplicationSonataDevisesBundle:Devises')->findOneByDate($date);
}
示例12: getDevisesValue
/**
* @static
* @param $id
* @param \DateTime $date
* @return int
*/
public static function getDevisesValue($id, \DateTime $date)
{
/* @var $doctrine \Doctrine\Bundle\DoctrineBundle\Registry */
$doctrine = \AppKernel::getStaticContainer()->get('doctrine');
/* @var $em \Doctrine\ORM\EntityManager */
$em = $doctrine->getManager();
/** @var $list_devises \Application\Sonata\ClientBundle\Entity\ListDevises */
$list_devises = $em->getRepository('ApplicationSonataClientBundle:ListDevises')->findOneById($id);
$devise = $em->getRepository('ApplicationSonataDevisesBundle:Devises')->findOneByDate(new \DateTime($date->format('Y-m-01')));
/** http://redmine.testenm.com/issues/1364 */
if ($list_devises->getAlias() == self::Device) {
return 1;
} elseif ($devise) {
$method = 'getMoney' . $list_devises->getAlias();
if (method_exists($devise, $method)) {
return $devise->{$method}();
}
}
}
示例13: queryResult
/**
* @param $params
* @return mixed
*/
protected function queryResult($params)
{
$admin = \AppKernel::getStaticContainer()->get('application.sonata.admin.' . strtolower($params['entity']));
/* \AppKernel::getStaticContainer()->setParameter('filter', array('client_id' => array('value' => $this->_client->getId())));
\AppKernel::getStaticContainer()->setParameter('month', $this->_month);
\AppKernel::getStaticContainer()->setParameter('year', $this->_year); */
$result = $admin->createQuery()->getQuery()->execute();
unset($admin);
return $result;
}
示例14: isGranted
public function isGranted($name, $object = null)
{
if ($name == 'DELETE') {
$user = \AppKernel::getStaticContainer()->get('security.context')->getToken()->getUser();
if ($user->hasGroup('Gestionnaire')) {
return false;
}
}
return parent::isGranted($name, $object);
}
示例15: __construct
public function __construct(Client $client)
{
$this->client = $client;
/* @var $em \Doctrine\ORM\EntityManager */
$this->em = \AppKernel::getStaticContainer()->get('doctrine')->getManager();
}