2014-05-23 09:35:56 +00:00
|
|
|
<?php namespace Cms\Classes;
|
|
|
|
|
|
2015-01-28 07:03:35 +00:00
|
|
|
use ApplicationException;
|
2015-04-03 23:34:25 +00:00
|
|
|
use Illuminate\Support\Collection as CollectionBase;
|
2014-05-23 09:35:56 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class represents a collection of Cms Objects.
|
|
|
|
|
*
|
|
|
|
|
* @package october\cms
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
|
|
|
|
class CmsObjectCollection extends CollectionBase
|
|
|
|
|
{
|
2015-04-03 23:34:25 +00:00
|
|
|
/**
|
|
|
|
|
* Returns objects that use the supplied component.
|
|
|
|
|
* @param string|array $components
|
|
|
|
|
* @return static
|
|
|
|
|
*/
|
|
|
|
|
public function withComponent($components)
|
|
|
|
|
{
|
|
|
|
|
return $this->filter(function($object) use ($components) {
|
|
|
|
|
|
|
|
|
|
$hasComponent = false;
|
|
|
|
|
|
|
|
|
|
foreach ((array) $components as $component) {
|
|
|
|
|
if ($object->hasComponent($component)) {
|
|
|
|
|
$hasComponent = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $hasComponent;
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-10-10 23:22:03 +00:00
|
|
|
}
|