-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mapped PuliFactory into Acme\ namespace
- Loading branch information
Showing
2 changed files
with
65 additions
and
4 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
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,59 @@ | ||
<?php | ||
|
||
namespace Acme; | ||
|
||
use Puli\Discovery\Api\ResourceDiscovery; | ||
use Puli\Discovery\KeyValueStoreDiscovery; | ||
use Puli\Repository\Api\ResourceRepository; | ||
use Puli\Repository\FilesystemRepository; | ||
use Webmozart\KeyValueStore\NullStore; | ||
|
||
/** | ||
* Creates Puli's core services. | ||
* | ||
* This class was auto-generated by Puli. | ||
* | ||
* IMPORTANT: Before modifying the code below, set the "factory.auto-generate" | ||
* configuration key to false: | ||
* | ||
* $ puli config factory.auto-generate false | ||
* | ||
* Otherwise any modifications will be overwritten! | ||
*/ | ||
class PuliFactory | ||
{ | ||
/** | ||
* Creates the resource repository. | ||
* | ||
* @return ResourceRepository The created resource repository. | ||
*/ | ||
public function createRepository() | ||
{ | ||
if (!file_exists(__DIR__.'/../../.puli/repository')) { | ||
mkdir(__DIR__.'/../../.puli/repository', 0777, true); | ||
} | ||
|
||
$repo = new FilesystemRepository(__DIR__.'/../../.puli/repository'); | ||
|
||
return $repo; | ||
} | ||
|
||
/** | ||
* Creates the resource discovery. | ||
* | ||
* @param ResourceRepository $repo The resource repository to read from. | ||
* | ||
* @return ResourceDiscovery The created resource discovery. | ||
*/ | ||
public static function createDiscovery(ResourceRepository $repo) | ||
{ | ||
$store = new NullStore(); | ||
|
||
$discovery = new KeyValueStoreDiscovery( | ||
$repo, | ||
$store | ||
); | ||
|
||
return $discovery; | ||
} | ||
} |