1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* (c) Christian Gripp <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Core23\FacebookBundle\Block\Service; |
13
|
|
|
|
14
|
|
|
use Facebook\Authentication\AccessToken; |
15
|
|
|
use Facebook\Facebook; |
16
|
|
|
use Psr\Log\LoggerAwareInterface; |
17
|
|
|
use Psr\Log\LoggerAwareTrait; |
18
|
|
|
use Psr\Log\NullLogger; |
19
|
|
|
use Sonata\BlockBundle\Block\Service\AbstractBlockService; |
20
|
|
|
use Sonata\BlockBundle\Block\Service\EditableBlockService; |
21
|
|
|
use Sonata\BlockBundle\Form\Mapper\FormMapper; |
22
|
|
|
use Sonata\BlockBundle\Model\BlockInterface; |
23
|
|
|
use Sonata\Form\Validator\ErrorElement; |
24
|
|
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
25
|
|
|
|
26
|
|
|
abstract class AbstractFacebookBlockService extends AbstractBlockService implements EditableBlockService, LoggerAwareInterface |
27
|
|
|
{ |
28
|
|
|
use LoggerAwareTrait; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var Facebook |
32
|
|
|
*/ |
33
|
|
|
private $facebook; |
34
|
|
|
|
35
|
|
|
public function __construct(string $name, EngineInterface $templating, Facebook $connection) |
36
|
|
|
{ |
37
|
|
|
parent::__construct($name, $templating); |
38
|
|
|
|
39
|
|
|
$this->facebook = $connection; |
40
|
|
|
$this->logger = new NullLogger(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function configureCreateForm(FormMapper $form, BlockInterface $block): void |
44
|
|
|
{ |
45
|
|
|
$this->configureEditForm($form, $block); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function validate(ErrorElement $errorElement, BlockInterface $block): void |
49
|
|
|
{ |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function getFacebook(): Facebook |
53
|
|
|
{ |
54
|
|
|
return $this->facebook; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
final protected function getAccessToken(): AccessToken |
58
|
|
|
{ |
59
|
|
|
return $this->facebook->getApp()->getAccessToken(); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|