Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Added CloudFront to list of available CDNs #687

Merged
merged 1 commit into from Apr 15, 2015

Conversation

phansys
Copy link
Member

@phansys phansys commented Dec 31, 2014

Added CloudFront to list of available CDNs
Any suggestion or improvement proposal are welcome.

Q A
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Doc PR none

TODO:

  • Unit testing
  • Update model in order to persist flush identifier
  • Create command to update flush status
  • Update translation catalogs

@phansys
Copy link
Member Author

phansys commented Jan 1, 2015

I have too some ideas about CDN usage / integration. IE, consider the following snippet attached to a lifecycle event or something similar:

#...
    $flushPaths = array();
    foreach ($provider->getFormats() as $format => $settings) {
        if ('admin' === $format || substr($format, 0, strlen($media->getContext())) == $media->getContext()) {
            $flushPaths[] = $provider->getFilesystem()->get($provider->generatePrivateUrl($media, $format))->getKey();
        }
    }
    if (!empty($flushPaths)) {
        $cdnFlushIdentifier = $provider->getCdn()->flushPaths($flushPaths);
        $media->setCdnFlushIdentifier($cdnFlushIdentifier);
        $media->setCdnIsFlushable(true);
        $media->setCdnStatus(CDNInterface::STATUS_TO_FLUSH);
    }

This also should take care about new_on_update form setting and only flush the CDN paths when it is set as false, because the "magically generated" new medias are fresh and aren't cached yet while the previous ones has kept immutables.

What do you think about?

By other side: should "cdnIsFlushable" become "flushingCdn" (deprecating the previous one)? since it is not being used to indicate whether the CDN supports flush, but to indicate that the flush is in process.

@phansys phansys changed the title Added CloudFront to list of available CDNs [WIP] Added CloudFront to list of available CDNs Jan 7, 2015
@phansys phansys force-pushed the cdn_cloudfront branch 3 times, most recently from 772aca9 to f1bc740 Compare January 9, 2015 19:45
@phansys
Copy link
Member Author

phansys commented Jan 19, 2015

I've rebased PR, squashed commits and added this logic in BaseProvider::transform() method.
Any concern about this feature will be great.

/cc @rande.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Doc PR        | none

* Sanitated starting and ending slashes in CloudFront::getPath()
* Replaced short array syntax [] in CloudFront::flushPaths() to keep BC with PHP 5.3
* Updated CloudFront CDN in order to throw custom exception while wrong paths given.
* Added unit tests for CloudFront.
* Added property "cdnFlushIdentifier" in BaseMedia.
* Updated CDNInterface and its implementations (added getFlushStatus() method).
* Added command to update CDN status for medias that are currently flushing.
* Updated translations.
* Normalized paths withouth leading slash.
* Throw exception while empty paths.
* Updated UpdateCdnStatusCommand (added verbose output).
* Normalized paths withouth leading slash.
* Added BaseProvider::flushCdn() method.
* Added check in BaseProvider to ensure CDN flush only in pre-existent medias.
* Bugfix in UpdateCdnStatusCommand.
rande added a commit that referenced this pull request Apr 15, 2015
[WIP] Added CloudFront to list of available CDNs
@rande rande merged commit 3f362e9 into sonata-project:master Apr 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants