mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
35 lines
827 B
PHP
35 lines
827 B
PHP
<?php namespace Cms\Classes;
|
|
|
|
use ApplicationException;
|
|
use Illuminate\Support\Collection as CollectionBase;
|
|
|
|
/**
|
|
* This class represents a collection of Cms Objects.
|
|
*
|
|
* @package october\cms
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
*/
|
|
class CmsObjectCollection extends CollectionBase
|
|
{
|
|
/**
|
|
* 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;
|
|
});
|
|
}
|
|
}
|