Skip to content

Commit

Permalink
Adding the ignored modules & Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Jul 24, 2015
1 parent ce26c4e commit 3b36a16
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/Repositories/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,28 @@ class Modules extends Repository
| ------------------------------------------------------------------------------------------------
*/
/**
* Get all modules.
*
* @return Collection
*/
* Get all modules.
*
* @return Collection
*/
public function all()
{
$modules = collect();

$this->getAllBasenames()->each(function($module) use ($modules) {
$modules->put($module, $this->getProperties($module));
if ( ! in_array($module, config('moduly.ignored', []))) {
$modules->put($module, $this->getProperties($module));
}
});

return $modules->sortBy('order');
}

/**
* Get all module slugs.
*
* @return Collection
*/
* Get all module slugs.
*
* @return Collection
*/
public function slugs()
{
return $this->all()->keys();
Expand Down Expand Up @@ -64,12 +66,12 @@ public function sortBy($key)
}

/**
* Sort modules by given key in ascending order.
*
* @param string $key
* Sort modules by given key in ascending order.
*
* @param string $key
*
* @return Collection
*/
* @return Collection
*/
public function sortByDesc($key)
{
return $this->all()->sortByDesc($key);
Expand Down Expand Up @@ -132,13 +134,13 @@ public function getProperty($property, $default = null)
}

/**
* Set the given module property value.
*
* @param string $property
* @param mixed $value
* Set the given module property value.
*
* @param string $property
* @param mixed $value
*
* @return bool
*/
* @return bool
*/
public function setProperty($property, $value)
{
list($module, $key) = explode('::', $property);
Expand All @@ -155,9 +157,11 @@ public function setProperty($property, $value)
}

$content[$key] = $value;
$content = json_encode($content, JSON_PRETTY_PRINT);

return $this->files->put($this->getManifestPath($module), $content);
return $this->files->put(
$this->getManifestPath($module),
json_encode($content, JSON_PRETTY_PRINT)
);
}

/**
Expand Down

0 comments on commit 3b36a16

Please sign in to comment.