/** * @internal * @param Scope $scope **/ private function figureOutWhichIncludes(Scope $scope) { $includes = $this->defaultIncludes; foreach ($this->availableIncludes as $include) { if ($scope->isRequested($include)) { $includes[] = $include; } } return $includes; }
/** * Figure out which includes we need. * * @internal * * @param Scope $scope * * @return array */ private function figureOutWhichIncludes(Scope $scope) { $includes = $this->getDefaultIncludes(); foreach ($this->getAvailableIncludes() as $include) { if ($scope->isRequested($include)) { $includes[] = $include; } } foreach ($includes as $include) { if ($scope->isExcluded($include)) { $includes = array_diff($includes, [$include]); } } return $includes; }
public function testIsRequested() { $manager = new Manager(); $manager->parseIncludes(array('foo', 'bar', 'baz.bart')); $scope = new Scope($manager, Mockery::mock('League\\Fractal\\Resource\\ResourceAbstract')); $this->assertTrue($scope->isRequested('foo')); $this->assertTrue($scope->isRequested('bar')); $this->assertTrue($scope->isRequested('baz')); $this->assertTrue($scope->isRequested('baz.bart')); $this->assertFalse($scope->isRequested('nope')); $childScope = $scope->embedChildScope('baz', Mockery::mock('League\\Fractal\\Resource\\ResourceAbstract')); $this->assertTrue($childScope->isRequested('bart')); $this->assertFalse($childScope->isRequested('foo')); $this->assertFalse($childScope->isRequested('bar')); $this->assertFalse($childScope->isRequested('baz')); }