Skip to content

Commit

Permalink
Mapped PuliFactory into Acme\ namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed Dec 29, 2014
1 parent 9971754 commit 6b77095
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
10 changes: 6 additions & 4 deletions puli.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"/acme/demo-bundle": "src/Acme/DemoBundle/Resources",
"/acme/demo-bundle/controller": "src/Acme/DemoBundle/Controller"
},
"config": {
"factory": {
"file": "src/Acme/PuliFactory.php",
"class": "Acme\\PuliFactory"
}
},
"packages": {
"seld/jsonlint": {
"install-path": "vendor/seld/jsonlint",
Expand Down Expand Up @@ -78,10 +84,6 @@
"install-path": "vendor/symfony/swiftmailer-bundle",
"installer": "Composer"
},
"sensiolabs/security-checker": {
"install-path": "vendor/sensiolabs/security-checker",
"installer": "Composer"
},
"sensio/distribution-bundle": {
"install-path": "vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle",
"installer": "Composer"
Expand Down
59 changes: 59 additions & 0 deletions src/Acme/PuliFactory.php
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;
}
}

0 comments on commit 6b77095

Please sign in to comment.