This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
[WIP] [2.0] Introduced the concept of loaders #294
Open
wouterj
wants to merge
9
commits into
symfony-cmf:master
Choose a base branch
from
wouterj:annotations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c01587d
Introduced the concept of loaders
wouterj b5f683f
Implemented annotations for SEO metadata information
wouterj 41d6532
Added PSR-6 cache integration
wouterj 9b22981
Symfony 3.1 is now stable
wouterj 36c95e2
Fix CS
wouterj 8f4618d
Added cache tests for AnnotationLoader
wouterj 0f04987
Removed unused test fixtures
wouterj 624327b
Use Prophecy in new tests
wouterj 05edab4
Minor typo fix
wouterj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,17 @@ Changelog | |
========= | ||
|
||
* **2016-06-18**: [BC BREAK] Removed all `*.class` parameters. | ||
* **2016-05-08**: [BC BREAK] Removed `showAtion` in favor of `listAction` in the `SuggestionProviderController`. | ||
* **2016-05-02**: [BC BREAK] Dropped PHP <5.5 support. | ||
* **2016-05-02**: [BC BREAK] Dropped Symfony <2.8 support. | ||
* **2016-05-31**: [BC BREAK] Removed `CacheInterface` and `FileCache`, use | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. showAction |
||
PSR-6 cache instead. | ||
* **2016-05-27**: [BC BREAK] Removed `SeoPresentation::addExtractor()`, use | ||
`ExtractorLoader::addExtractor()` instead. | ||
* **2016-05-27**: [BC BREAK] Changed the fourth argument of the constructor of | ||
`SeoPresentation` from `CacheInterface` to `LoaderInterface`. | ||
* **2016-05-27**: Added loaders. | ||
* **2016-05-08**: [BC BREAK] Removed `showAtion` in favor of `listAction` in | ||
the `SuggestionProviderController` | ||
* **2016-05-02**: [BC BREAK] Dropped PHP <5.5 support | ||
* **2016-05-02**: [BC BREAK] Dropped Symfony <2.8 support | ||
|
||
1.3.0 | ||
----- | ||
|
@@ -22,15 +30,15 @@ Changelog | |
* **2015-08-20**: Added templates configuration and `exclusion_rules` (based on the request matcher) to | ||
the error handling configuration | ||
* **2015-08-12**: Added configuration for the default data class of the `seo_metadata` form type. | ||
* **2015-07-20**: Cleaned up the sitemap generation. If you used the unreleased | ||
* **2015-07-20**: Cleaned up the sitemap generation. If you used the unreleased | ||
version of sitemaps, you will need to adjust your code. See https://github.com/symfony-cmf/SeoBundle/pull/225 | ||
Options are available to keep all or no voters|guessers|loaders enabled or | ||
Options are available to keep all or no voters|guessers|loaders enabled or | ||
enable them one by one by their service id. | ||
* **2015-02-24**: Configuration for `content_key` moved to the `content_listener` | ||
section, and its now possible to disable the content listener by setting | ||
* **2015-02-24**: Configuration for `content_key` moved to the `content_listener` | ||
section, and its now possible to disable the content listener by setting | ||
`cmf_seo.content_listener.enabled: false` | ||
* **2015-02-14**: Added sitemap generation | ||
* **2015-02-14**: [BC BREAK] Changed method visibility of | ||
* **2015-02-14**: [BC BREAK] Changed method visibility of | ||
`SeoPresentation#getSeoMetadata()` from private to public. | ||
* **2014-10-04**: Custom exception controller for error handling. | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,16 +12,16 @@ | |
namespace Symfony\Cmf\Bundle\SeoBundle\Cache; | ||
|
||
/** | ||
* Contains the extractors for one particular content object. | ||
* Contains the cached data for one particular content object. | ||
* | ||
* @author Wouter J <[email protected]> | ||
*/ | ||
class ExtractorCollection implements \IteratorAggregate, \Serializable | ||
class CachedCollection implements \IteratorAggregate, \Serializable | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $extractors; | ||
private $data; | ||
|
||
/** | ||
* @var null|string | ||
|
@@ -34,23 +34,53 @@ class ExtractorCollection implements \IteratorAggregate, \Serializable | |
private $createdAt; | ||
|
||
/** | ||
* @param array $extractors | ||
* @param null|string $resource The path to the file of the content object, this is | ||
* used to determine if the cache needs to be updated | ||
* @param array $data | ||
* @param null|string $resource The path to the file of the content object, this is | ||
* used to determine if the cache needs to be updated | ||
*/ | ||
public function __construct(array $extractors, $resource = null) | ||
public function __construct(array $data, $resource = null) | ||
{ | ||
$this->extractors = $extractors; | ||
$this->data = $data; | ||
$this->resource = $resource; | ||
$this->createdAt = time(); | ||
} | ||
|
||
/** | ||
* Creates a CachedCollection based on the object and data to cache. | ||
* | ||
* @param object|string $objectOrClass Object instance or FQCN | ||
* @param array $data | ||
* | ||
* @return static | ||
*/ | ||
public static function createFromObject($objectOrClass, array $data) | ||
{ | ||
$class = is_object($objectOrClass) ? get_class($objectOrClass) : $objectOrClass; | ||
|
||
static $fileLocations = []; | ||
if (!isset($fileLocations[$class])) { | ||
$fileLocations[$class] = (new \ReflectionClass($objectOrClass))->getFileName(); | ||
} | ||
|
||
return new static($data, $fileLocations[$class]); | ||
} | ||
|
||
public static function generateCacheItemKey($type, $class) | ||
{ | ||
return sprintf('cmf_seo.%s.%s', $type, str_replace('\\', '.', $class)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getIterator() | ||
{ | ||
return new \ArrayIterator($this->extractors); | ||
return new \ArrayIterator($this->data); | ||
} | ||
|
||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
|
||
/** | ||
|
@@ -83,7 +113,7 @@ public function isFresh($timestamp = null) | |
public function serialize() | ||
{ | ||
return serialize(array( | ||
$this->extractors, | ||
$this->data, | ||
$this->resource, | ||
$this->createdAt, | ||
)); | ||
|
@@ -95,7 +125,7 @@ public function serialize() | |
public function unserialize($data) | ||
{ | ||
list( | ||
$this->extractors, | ||
$this->data, | ||
$this->resource, | ||
$this->createdAt | ||
) = unserialize($data); | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,11 @@ class RegisterExtractorsPass implements CompilerPassInterface | |
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('cmf_seo.presentation')) { | ||
if (!$container->hasDefinition('cmf_seo.loader.extractor')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't rename the class too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's still the extractor registerer, so no need to rename the class |
||
return; | ||
} | ||
|
||
$strategyDefinition = $container->getDefinition('cmf_seo.presentation'); | ||
$strategyDefinition = $container->getDefinition('cmf_seo.loader.extractor'); | ||
$taggedServices = $container->findTaggedServiceIds('cmf_seo.extractor'); | ||
|
||
foreach ($taggedServices as $id => $attributes) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is LTS for 5.6 over now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, 5.6 is still tested (see the PHP version list). However, when testing all different supported Symfony versions, we should use the latest version around (as it's the quickest).