GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bd1580...0ea8fb )
by Florian
09:56
created

AbstractSearchService::setFacetContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the Stinger Entity Search package.
6
 *
7
 * (c) Oliver Kotte <[email protected]>
8
 * (c) Florian Meyer <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace StingerSoft\EntitySearchBundle\Services;
15
16
use Doctrine\Common\Persistence\ObjectManager;
17
use Doctrine\Common\Util\ClassUtils;
18
use Psr\Container\ContainerInterface;
19
use StingerSoft\EntitySearchBundle\Model\Document;
20
use StingerSoft\EntitySearchBundle\Model\DocumentAdapter;
21
use StingerSoft\EntitySearchBundle\Services\Facet\FacetServiceInterface;
22
23
abstract class AbstractSearchService implements SearchService {
24
25
	/**
26
	 *
27
	 * @var ObjectManager
28
	 */
29
	protected $objectManager;
30
31
	/**
32
	 * @var ContainerInterface
33
	 */
34
	protected $facetContainer;
35
36
	/**
37
	 *
38
	 * {@inheritdoc}
39
	 *
40
	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::getObjectManager()
41
	 */
42
	public function getObjectManager(): ObjectManager {
43
		return $this->objectManager;
44
	}
45
46
	/**
47
	 *
48
	 * {@inheritdoc}
49
	 *
50
	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::setObjectManager()
51
	 *
52
	 * @required
53
	 */
54
	public function setObjectManager(ObjectManager $om): void {
55
		if($this->objectManager)
56
			return;
57
		$this->objectManager = $om;
58
	}
59
60
	/**
61
	 *
62
	 * {@inheritdoc}
63
	 *
64
	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::setFacetContainer()
65
	 */
66
	public function setFacetContainer(ContainerInterface $facetContainer): void {
67
		$this->facetContainer = $facetContainer;
68
	}
69
70
	/**
71
	 *
72
	 * {@inheritdoc}
73
	 *
74
	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::getFacet()
75
	 */
76
	public function getFacet(string $facetId): FacetServiceInterface {
77
		return $this->facetContainer->get($facetId);
78
	}
79
80
	/**
81
	 *
82
	 * {@inheritdoc}
83
	 *
84
	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::createEmptyDocumentFromEntity()
85
	 */
86
	public function createEmptyDocumentFromEntity(object $entity): Document {
87
		$document = $this->newDocumentInstance();
88
		$clazz = $this->getClass($entity);
89
		$cmd = $this->getObjectManager()->getClassMetadata($clazz);
90
		$id = $cmd->getIdentifierValues($entity);
91
92
		$document->setEntityClass($clazz);
93
		$document->setEntityId(count($id) == 1 ? current($id) : $id);
94
		return $document;
95
	}
96
97
	/**
98
	 *
99
	 * {@inheritdoc}
100
	 *
101
	 * @see \StingerSoft\EntitySearchBundle\Services\SearchService::getOnlineHelp()
102
	 */
103
	public function getOnlineHelp(string $locale, string $defaultLocale = 'en'): ?string {
104
		return null;
105
	}
106
107
	protected function getClass($entity): string {
108
		return ClassUtils::getClass($entity);
109
	}
110
111
	/**
112
	 * Creates a new document instance
113
	 *
114
	 * @return Document
115
	 */
116
	protected function newDocumentInstance(): Document {
117
		return new DocumentAdapter();
118
	}
119
}