1 | <?php |
||
20 | class PageCreatorService |
||
21 | { |
||
22 | /** @var EntityManagerInterface */ |
||
23 | protected $entityManager; |
||
24 | |||
25 | /** @var ACLPermissionCreatorService */ |
||
26 | protected $aclPermissionCreatorService; |
||
27 | |||
28 | /** @var string */ |
||
29 | protected $userEntityClass; |
||
30 | |||
31 | public function __construct(EntityManagerInterface $em = null, ACLPermissionCreatorService $aclPermissionCreatorService = null, string $userEntityClass = null) |
||
32 | { |
||
33 | if (null === $em) { |
||
34 | @trigger_error(sprintf('Not injecting the required dependencies in the constructor of "%s" is deprecated since KunstmaanNodeBundle 5.7 and will be required in KunstmaanNodeBundle 6.0.', __CLASS__), E_USER_DEPRECATED); |
||
|
|||
35 | } |
||
36 | |||
37 | $this->entityManager = $em; |
||
38 | $this->aclPermissionCreatorService = $aclPermissionCreatorService; |
||
39 | $this->userEntityClass = $userEntityClass; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @deprecated since KunstmaanNodeBundle 5.7 and will be removed in KunstmaanNodeBundle 6.0. Inject the required dependencies in the constructor instead. |
||
44 | */ |
||
45 | public function setEntityManager($entityManager) |
||
51 | |||
52 | /** |
||
53 | * @deprecated since KunstmaanNodeBundle 5.7 and will be removed in KunstmaanNodeBundle 6.0. Inject the required dependencies in the constructor instead. |
||
54 | */ |
||
55 | public function setACLPermissionCreatorService($aclPermissionCreatorService) |
||
61 | |||
62 | /** |
||
63 | * @deprecated since KunstmaanNodeBundle 5.7 and will be removed in KunstmaanNodeBundle 6.0. Inject the required dependencies in the constructor instead. |
||
64 | */ |
||
65 | public function setUserEntityClass($userEntityClass) |
||
71 | |||
72 | /** |
||
73 | * Sets the Container. This is still here for backwards compatibility. |
||
74 | * |
||
75 | * The ContainerAwareInterface has been removed so the container won't be injected automatically. |
||
76 | * This function is just there for code that calls it manually. |
||
77 | * |
||
78 | * @param ContainerInterface $container a ContainerInterface instance |
||
79 | * |
||
80 | * @deprecated since KunstmaanNodeBundle 5.7 and will be removed in KunstmaanNodeBundle 6.0. Inject the required dependencies in the constructor instead. |
||
81 | * |
||
82 | * @api |
||
83 | */ |
||
84 | public function setContainer(ContainerInterface $container = null) |
||
92 | |||
93 | /** |
||
94 | * @param HasNodeInterface $pageTypeInstance the page |
||
95 | * @param array $translations Containing arrays. Sample: |
||
96 | * [ |
||
97 | * [ "language" => "nl", |
||
98 | * "callback" => function($page, $translation) { |
||
99 | * $translation->setTitle('NL titel'); |
||
100 | * } |
||
101 | * ], |
||
102 | * [ "language" => "fr", |
||
103 | * "callback" => function($page, $translation) { |
||
104 | * $translation->setTitle('FR titel'); |
||
105 | * } |
||
106 | * ] |
||
107 | * ] |
||
108 | * Perhaps it's cleaner when you create one array and append another array for each language. |
||
109 | * @param array $options Possible options: |
||
110 | * parent: type node, nodetransation or page. |
||
111 | * page_internal_name: string. name the page will have in the database. |
||
112 | * set_online: bool. if true the page will be set as online after creation. |
||
113 | * hidden_from_nav: bool. if true the page will not be show in the navigation |
||
114 | * creator: username |
||
115 | * |
||
116 | * Automatically calls the ACL + sets the slugs to empty when the page is an Abstract node. |
||
117 | * |
||
118 | * @return Node the new node for the page |
||
119 | * |
||
120 | * @throws \InvalidArgumentException |
||
121 | */ |
||
122 | public function createPage(HasNodeInterface $pageTypeInstance, array $translations, array $options = array()) |
||
240 | } |
||
241 |
If you suppress an error, we recommend checking for the error condition explicitly: