From 20f25f1c767c43f1b16496de8db79c5ae4099d8f Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 12 Apr 2016 12:27:33 -0400 Subject: [PATCH 1/4] Issue #2704791: Check autoload in hook_requirements --- fb_instant_articles.install | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fb_instant_articles.install b/fb_instant_articles.install index b169cfa..4355853 100644 --- a/fb_instant_articles.install +++ b/fb_instant_articles.install @@ -19,3 +19,28 @@ function fb_instant_articles_uninstall() { variable_del('fb_instant_articles_analytics_embed_code'); variable_del('fb_instant_articles_enable_logging'); } + +/** + * Implements hook_requirements(). + */ +function fb_instant_articles__requirements() { + $requirements = array(); + $t = get_t(); + + if (!class_exists('\Facebook\InstantArticles\Client\Client')) { + $string = 'The Facebook Instant Articles module requires the + facebook-instant-articles-sdk-php library, and Composer autoloading. The + easiest way to set this up is to enable the + Composer manager module, which autoloads classes needed for the Facebook + Instant Articles SDK, and downloads the SDK automatically when you enable the + base module. Composer manager is not a literal dependency so that developers + with custom Composer workflows can choose to manage dependencies and + autoloading themselves (if this is the case you will need to include + Composer\'s autoload file somewhere in your code).'; + $args = array('@composer-manager' => 'https://drupal.org/project/composer_manager'); + $requirements['autoload']['description'] = $t($string, $args); + $requirements['autoload']['severity'] = REQUIREMENT_ERROR; + } + + return $requirements; +} From b62d2283d1e4f5d4e9b766cf49e112d00e9ac2e2 Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 12 Apr 2016 14:29:30 -0400 Subject: [PATCH 2/4] Fix hook name typo --- fb_instant_articles.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fb_instant_articles.install b/fb_instant_articles.install index 4355853..c78e9fb 100644 --- a/fb_instant_articles.install +++ b/fb_instant_articles.install @@ -23,7 +23,7 @@ function fb_instant_articles_uninstall() { /** * Implements hook_requirements(). */ -function fb_instant_articles__requirements() { +function fb_instant_articles_requirements() { $requirements = array(); $t = get_t(); From cb1d5035fca9cc1f7d140f74d65bdc4bdee3805d Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 12 Apr 2016 15:14:57 -0400 Subject: [PATCH 3/4] Check variable to bypass composer_manager for autoloading and dependencies --- fb_instant_articles.install | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fb_instant_articles.install b/fb_instant_articles.install index c78e9fb..48918a0 100644 --- a/fb_instant_articles.install +++ b/fb_instant_articles.install @@ -18,6 +18,7 @@ function fb_instant_articles_uninstall() { variable_del('fb_instant_articles_ads_embed_code'); variable_del('fb_instant_articles_analytics_embed_code'); variable_del('fb_instant_articles_enable_logging'); + variable_del('fb_instant_articles_bypass_composer_manager'); } /** @@ -27,7 +28,10 @@ function fb_instant_articles_requirements() { $requirements = array(); $t = get_t(); - if (!class_exists('\Facebook\InstantArticles\Client\Client')) { + $bypass_composer_manager = variable_get('fb_instant_articles_bypass_composer_manager'); + $composer_manager_enabled = module_exists('composer_manager'); + + if (!($bypass_composer_manager || $composer_manager_enabled)) { $string = 'The Facebook Instant Articles module requires the facebook-instant-articles-sdk-php library, and Composer autoloading. The easiest way to set this up is to enable the From 1c854703e39216953e749faa9002dd0e574fdfd9 Mon Sep 17 00:00:00 2001 From: Scott Rigby Date: Tue, 12 Apr 2016 15:16:37 -0400 Subject: [PATCH 4/4] Update README for new variable fb_instant_articles_bypass_composer_manager, and fix all whitespace errors --- README.md | 106 +++++++++++++++++++++++++++--------------------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 76ed5f4..814384f 100644 --- a/README.md +++ b/README.md @@ -1,97 +1,99 @@ # Drupal Facebook Instant Articles -The Facebook Instant Articles modules allow administrators to add content from a -Drupal site to Facebook, to be viewed on mobile devices as Instant Articles. +The Facebook Instant Articles modules allow administrators to add content from a + Drupal site to Facebook, to be viewed on mobile devices as Instant Articles. ## About the Facebook Instant Articles service Facebook has [introductory information for publishers](https://instantarticles.fb.com/) -as well as [in-depth documentation for developers](https://developers.facebook.com/docs/instant-articles). + as well as [in-depth documentation for developers](https://developers.facebook.com/docs/instant-articles). ## About Drupal integration -Before installing this module or packaged sub-modules, there are two methods to -choose from for how to add your content to Facebook as Instant Articles (either -via a feed or Facebook's API), and then simple or advanced options for each. +Before installing this module or packaged sub-modules, there are two methods to + choose from for how to add your content to Facebook as Instant Articles (either + via a feed or Facebook's API), and then simple or advanced options for each. ### 1. Feed method -On a basic Drupal site, with one or more article-like content types that you -wish to post to Facebook as Instant Articles, the simplest way is to create a -feed from your Drupal site and then have your Facebook page admin configure -the Instant Articles options to point to your website to ingest the feed. +On a basic Drupal site, with one or more article-like content types that you + wish to post to Facebook as Instant Articles, the simplest way is to create a + feed from your Drupal site and then have your Facebook page admin configure + the Instant Articles options to point to your website to ingest the feed. -You'll need to configure which content types you want to be allowable as Instant -Articles, then configure a view mode to specify which fields you want to map to -which region of the Instant Article format, then you're all ready to create the -feed. +You'll need to configure which content types you want to be allowable as Instant + Articles, then configure a view mode to specify which fields you want to map to + which region of the Instant Article format, then you're all ready to create the + feed. -To create the actual feed, there are two main options: a simple RSS feed, or a -more advanced feed using the [Views module](https://www.drupal.org/project/views). +To create the actual feed, there are two main options: a simple RSS feed, or a + more advanced feed using the [Views module](https://www.drupal.org/project/views). #### RSS feed (simple) -If you enable the fb_instant_articles_rss.module you will have a feed created -for you automatically. You will then have the option to either add all published -content of one or more types to the feed, or else select individual pieces of -content to be included in the feed. +If you enable the fb_instant_articles_rss.module you will have a feed created + for you automatically. You will then have the option to either add all + published content of one or more types to the feed, or else select individual + pieces of content to be included in the feed. #### Views feed (advanced) Alternately, if you enable the fb_instant_articles_views.module you will be able -to choose more advanced filtering rules for which content is included in the -feed. Currently only a rendered view mode (not a fields view) is supported. + to choose more advanced filtering rules for which content is included in the + feed. Currently only a rendered view mode (not a fields view) is supported. ### 2. API method -If you're a publisher who wants more control over exact timing of publishing - -editing, modifying public access, or removing content from your Facebook Instant -Articles library - the API approach allows for greater control. +If you're a publisher who wants more control over exact timing of publishing - + editing, modifying public access, or removing content from your Facebook + Instant Articles library - the API approach allows for greater control. #### API Rules integration (optional) If you're using the API you will need to determine under what conditions the API -creates, edits or removes content from Facebook's Instant Articles library. This -submodule adds actions (both Drupal core actions and [Rules](https://drupal.org/project/rules) -module actions) which can be triggered based on your chosen configurations. -Alternately, If you do not choose to use this module to trigger API actions, you -will want to trigger them some other way (via a custom module implementing -entity CRUD hooks checking your own custom conditions in code, etc). + creates, edits or removes content from Facebook's Instant Articles library. + This submodule adds actions (both Drupal core actions and + [Rules](https://drupal.org/project/rules) module actions) which can be + triggered based on your chosen configurations. Alternately, If you do not + choose to use this module to trigger API actions, you + will want to trigger them some other way (via a custom module implementing + entity CRUD hooks checking your own custom conditions in code, etc). #### API Report (optional) -Optionally enable this module to give a report of API interactions, so that for -example any content that fails Facebook Instant Article format validation will -be easier to find and fix. +Optionally enable this module to give a report of API interactions, so that for + example any content that fails Facebook Instant Article format validation will + be easier to find and fix. ## Dependencies -The Drupal Facebook Instant Articles modules have different dependencies, see -"About Drupal integration" above to help choose which modules are right for you -(see each module's README for it's dependencies). +The Drupal Facebook Instant Articles modules have different dependencies, see + "About Drupal integration" above to help choose which modules are right for you + (see each module's README for it's dependencies). - - [Facebook Instant Articles PHP SDK](https://github.com/facebook/facebook-instant-articles-sdk-php) -provides necessary support for ensuring Drupal content is added to facebook in -the required format for Instant Articles. + - [Facebook Instant Articles PHP SDK](https://github.com/facebook/facebook-instant-articles-sdk-php) + provides necessary support for ensuring Drupal content is added to facebook in + the required format for Instant Articles. ## Strongly recommended: -- [Composer Manager](https://www.drupal.org/project/composer_manager) autoloads -classes needed for the Facebook Instant Articles SDK, and downloads the SDK -automatically when you enable the base module. Composer manager is not a literal -dependency so that developers with custom Composer workflows can choose to -manage dependencies and autoloading themselves (if this is the case you will -need to include Composer's autoload file somewhere in your code). +- [Composer Manager](https://www.drupal.org/project/composer_manager) autoloads + classes needed for the Facebook Instant Articles SDK, and downloads the SDK + automatically when you enable the base module. Composer manager is not a + literal dependency so that developers with custom Composer workflows can choose + to manage dependencies and autoloading themselves (if this is the case you will + need to include Composer's autoload file somewhere in your code, and set the + variable 'fb_instant_articles_bypass_composer_manager' to TRUE). ## Installation -Before installing the Drupal Facebook Instant Articles modules, see "About -Drupal integration" above to help choose which modules are right for you. Then -see "Dependencies" above. Then: +Before installing the Drupal Facebook Instant Articles modules, see "About + Drupal integration" above to help choose which modules are right for you. Then + see "Dependencies" above. Then: -- Install the submodules you choose as you would normally install a contributed -Drupal module. See [Installing modules (Drupal 7)](https://drupal.org/documentation/install/modules-themes/modules-7) -for further information. +- Install the submodules you choose as you would normally install a contributed + Drupal module. See [Installing modules (Drupal 7)](https://drupal.org/documentation/install/modules-themes/modules-7) + for further information. ## Configuration