-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from it-blaster/devel
Devel
- Loading branch information
Showing
34 changed files
with
657 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace ItBlaster\CounterManagementBundle\Admin; | ||
|
||
use Sonata\AdminBundle\Admin\Admin; | ||
use Sonata\AdminBundle\Datagrid\DatagridMapper; | ||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
use Sonata\AdminBundle\Form\FormMapper; | ||
use Sonata\AdminBundle\Show\ShowMapper; | ||
|
||
class GoalAdmin extends Admin | ||
{ | ||
/** | ||
* @param DatagridMapper $datagridMapper | ||
*/ | ||
protected function configureDatagridFilters(DatagridMapper $datagridMapper) | ||
{ | ||
$datagridMapper | ||
->add('Name') | ||
->add('Code') | ||
->add('Counter') | ||
->add('Page') | ||
->add('ButtonType') | ||
->add('Vendor') | ||
; | ||
} | ||
|
||
/** | ||
* @param ListMapper $listMapper | ||
*/ | ||
protected function configureListFields(ListMapper $listMapper) | ||
{ | ||
$listMapper | ||
->add('Id') | ||
->add('Name') | ||
->add('Code') | ||
->add('Counter') | ||
->add('Page') | ||
->add('ButtonType') | ||
->add('Vendor') | ||
->add('_action', 'actions', array( | ||
'actions' => array( | ||
'show' => array(), | ||
'edit' => array(), | ||
'delete' => array(), | ||
) | ||
)) | ||
; | ||
} | ||
|
||
/** | ||
* @param FormMapper $formMapper | ||
*/ | ||
protected function configureFormFields(FormMapper $formMapper) | ||
{ | ||
$formMapper | ||
->add('Id') | ||
->add('Name') | ||
->add('Code') | ||
->add('Counter') | ||
->add('Page') | ||
->add('ButtonType') | ||
->add('Vendor') | ||
; | ||
} | ||
|
||
/** | ||
* @param ShowMapper $showMapper | ||
*/ | ||
protected function configureShowFields(ShowMapper $showMapper) | ||
{ | ||
$showMapper | ||
->add('Id') | ||
->add('Name') | ||
->add('Code') | ||
->add('Counter') | ||
->add('Page') | ||
->add('ButtonType') | ||
->add('Vendor') | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
namespace ItBlaster\CounterManagementBundle\Admin; | ||
|
||
use Sonata\AdminBundle\Admin\Admin; | ||
use Sonata\AdminBundle\Datagrid\DatagridMapper; | ||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
use Sonata\AdminBundle\Form\FormMapper; | ||
use Sonata\AdminBundle\Route\RouteCollection; | ||
use Sonata\AdminBundle\Show\ShowMapper; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
|
||
class WebCounterAdmin extends Admin | ||
{ | ||
/** | ||
* @param DatagridMapper $datagridMapper | ||
*/ | ||
protected function configureDatagridFilters(DatagridMapper $datagridMapper) | ||
{ | ||
$datagridMapper | ||
->add('Name', null, array( | ||
'label' => 'Название' | ||
)) | ||
->add('Published', null, array( | ||
'label' => 'Публикация' | ||
)) | ||
; | ||
} | ||
|
||
protected function configureRoutes(RouteCollection $collection) | ||
{ | ||
parent::configureRoutes($collection); | ||
$collection->remove('show'); | ||
} | ||
|
||
|
||
/** | ||
* @param ListMapper $listMapper | ||
*/ | ||
protected function configureListFields(ListMapper $listMapper) | ||
{ | ||
$listMapper | ||
->add('Name', null, array( | ||
'label' => 'Название' | ||
)) | ||
->add('Number', null, array( | ||
'label' => 'Номер' | ||
)) | ||
->add('TypeKey', null, array( | ||
'label' => 'Тип', | ||
)) | ||
->add('_action', 'actions', array( | ||
'actions' => array( | ||
'show' => array(), | ||
'edit' => array(), | ||
'delete' => array(), | ||
) | ||
)) | ||
; | ||
} | ||
|
||
/** | ||
* @param FormMapper $formMapper | ||
*/ | ||
protected function configureFormFields(FormMapper $formMapper) | ||
{ | ||
$formMapper | ||
->add('Name', null, array( | ||
'label' => 'Название', | ||
'required' => true, | ||
'constraints' => array( | ||
new NotBlank() | ||
) | ||
)) | ||
->add('Number', null, array( | ||
'label' => 'Номер счетчика', | ||
'required' => true, | ||
'constraints' => array( | ||
new NotBlank() | ||
) | ||
)) | ||
->add('Code', null, array( | ||
'label' => 'Код счетчика', | ||
'disabled' => true, | ||
)) | ||
->add('TypeKey', 'choice', array( | ||
'label' => 'Тип счетчика', | ||
'choices' => $this->getConfigurationPool()->getContainer()->get('counter_management.manager')->getProvidersChoices(), | ||
'constraints' => array( | ||
new NotBlank() | ||
) | ||
)); | ||
} | ||
|
||
/** | ||
* @param ShowMapper $showMapper | ||
*/ | ||
protected function configureShowFields(ShowMapper $showMapper) | ||
{ | ||
$showMapper | ||
->add('Id') | ||
->add('Name') | ||
->add('Published') | ||
->add('Code') | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace ItBlaster\CounterManagementBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
|
||
class CounterAddCommand extends ContainerAwareCommand { | ||
|
||
|
||
protected function configure() | ||
{ | ||
$this | ||
->setName('counters:add') | ||
->setDescription('Create counter') | ||
->addArgument( | ||
'type', | ||
InputArgument::OPTIONAL, | ||
'What kind of counter do u want to create?' | ||
) | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
|
||
$counter = $this->getContainer()->get('counter_management.manager') | ||
->getProvider('yandex_metrika')->create(array('code' => '5742498')); | ||
|
||
var_dump($counter); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
DependencyInjection/Compiler/CounterManagementProviderCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
|
||
namespace ItBlaster\CounterManagementBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
|
||
class CounterManagementProviderCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->has('counter_management.manager')) { | ||
return; | ||
} | ||
|
||
$definition = $container->findDefinition( | ||
'counter_management.manager' | ||
); | ||
|
||
$taggedServices = $container->findTaggedServiceIds( | ||
'counter_management.provider' | ||
); | ||
|
||
foreach ($taggedServices as $id => $tags) { | ||
$definition->addMethodCall( | ||
'addProvider', | ||
array(new Reference($id)) | ||
); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
|
||
namespace ItBlaster\CounterManagementBundle\Listener; | ||
|
||
|
||
use ItBlaster\CounterManagementBundle\Model\WebCounter; | ||
use ItBlaster\CounterManagementBundle\Model\WebCounterPeer; | ||
use ItBlaster\CounterManagementBundle\Service\Manager; | ||
use Symfony\Component\EventDispatcher\GenericEvent; | ||
|
||
class WebCounterListener | ||
{ | ||
|
||
|
||
/** | ||
* @var Manager | ||
*/ | ||
protected $counter_management_manager; | ||
|
||
/** | ||
* WebCounterListener constructor. | ||
* @param Manager $counter_management_manager | ||
*/ | ||
public function __construct(Manager $counter_management_manager) | ||
{ | ||
$this->counter_management_manager = $counter_management_manager; | ||
} | ||
|
||
public function onPreSave(GenericEvent $event) | ||
{ | ||
/** @var WebCounter $web_counter */ | ||
$web_counter = $event->getSubject(); | ||
if ($web_counter->isColumnModified(WebCounterPeer::NUMBER) || $web_counter->getCode() === null) { | ||
$this->generateCode($web_counter); | ||
} | ||
} | ||
|
||
/** | ||
* @param WebCounter $web_counter | ||
*/ | ||
protected function generateCode(WebCounter $web_counter) | ||
{ | ||
$provider = $this->counter_management_manager->getProvider($web_counter->getTypeKey()); | ||
$web_counter->setCode( | ||
$provider->generateCode($web_counter->getNumber()) | ||
); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace ItBlaster\CounterManagementBundle\Model; | ||
|
||
use ItBlaster\CounterManagementBundle\Model\om\BaseWebCounter; | ||
|
||
class WebCounter extends BaseWebCounter | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace ItBlaster\CounterManagementBundle\Model; | ||
|
||
use ItBlaster\CounterManagementBundle\Model\om\BaseWebCounterGoal; | ||
|
||
class WebCounterGoal extends BaseWebCounterGoal | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace ItBlaster\CounterManagementBundle\Model; | ||
|
||
use ItBlaster\CounterManagementBundle\Model\om\BaseWebCounterGoalPeer; | ||
|
||
class WebCounterGoalPeer extends BaseWebCounterGoalPeer | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace ItBlaster\CounterManagementBundle\Model; | ||
|
||
use ItBlaster\CounterManagementBundle\Model\om\BaseWebCounterGoalQuery; | ||
|
||
class WebCounterGoalQuery extends BaseWebCounterGoalQuery | ||
{ | ||
} |
Oops, something went wrong.