Completed
Pull Request — develop (#263)
by Oliver
41:50 queued 26:57
created

AbstractDatagrid::initGrid()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
namespace ZfcDatagrid\Service;
3
4
use Interop\Container\ContainerInterface;
5
use InvalidArgumentException;
6
use Zend\ServiceManager\Factory\FactoryInterface;
7
use ZfcDatagrid\Datagrid;
8
9
abstract class AbstractDatagrid extends Datagrid implements FactoryInterface
10
{
11
    /**
12
     * @param ContainerInterface $container
13
     * @param string             $requestedName
14
     * @param array|null         $options
15
     *
16
     * @return $this
17
     */
18
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
19
    {
20
        $this->setServiceLocator($container);
21
        $config = $container->get('config');
22
23
        if (!isset($config['ZfcDatagrid'])) {
24
            throw new InvalidArgumentException('Config key "ZfcDatagrid" is missing');
25
        }
26
27
        /* @var $application \Zend\Mvc\Application */
28
        $application = $container->get('application');
29
30
        parent::setOptions($config['ZfcDatagrid']);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setOptions() instead of __invoke()). Are you sure this is correct? If so, you might want to change this to $this->setOptions().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
31
        parent::setMvcEvent($application->getMvcEvent());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setMvcEvent() instead of __invoke()). Are you sure this is correct? If so, you might want to change this to $this->setMvcEvent().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
32
33
        if ($container->has('translator') === true) {
34
            parent::setTranslator($container->get('translator'));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setTranslator() instead of __invoke()). Are you sure this is correct? If so, you might want to change this to $this->setTranslator().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
35
        }
36
37
        parent::setRendererService($container->get('zfcDatagrid.renderer.' . parent::getRendererName()));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getRendererName() instead of __invoke()). Are you sure this is correct? If so, you might want to change this to $this->getRendererName().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setRendererService() instead of __invoke()). Are you sure this is correct? If so, you might want to change this to $this->setRendererService().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
38
        parent::init();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (init() instead of __invoke()). Are you sure this is correct? If so, you might want to change this to $this->init().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
39
40
        return $this;
41
    }
42
43
    /**
44
     * Call initGrid on rendering.
45
     */
46
    public function render()
47
    {
48
        $this->initGrid();
49
50
        parent::render();
51
    }
52
53
    abstract public function initGrid();
54
}
55