About

To learn more read my blog or visit the links in upper right.

Blog

Six months ago or so it clearly stated in the Drupal docs to NOT create D8 modules do to the API not being finished. But still right and left there were people developing and porting D8 modules, clients were asking for it as experience and there was a log of hype. I decided to try my hand at it and had a working module as of 6 months ago. When I finally got GIT access 6 months later to push my changes to Fancy Login, It had stopped working on the latest D8 build. This article covers the latest changes to the API made during this period and the changes I had to make to do last minute API changes.
module Fancy Login.

1. moved file FancyLoginSettingsForm.php from folder fancy_login/src to fancy_login/src/Form folder

2. in FancyLoginSettingsForm.php file changed translate functions functions t(). for example

t('Text !url.', array('!url' => 'background-

color')) to t('Text background-color', array('@url' =>

'http://themeshift.com'))

3. Moved the function user_login_block_ajax_callback from file FancyLoginSettingsForm.php to

fancy_login.module file.

4. Moved libraries such as

Drupal\Core\Ajax\AjaxResponse;

Drupal\lightbox_login\Ajax\lightboxLoginRefreshPageCommand;

Drupal\lightbox_login\Ajax\lightboxLoginRedirectCommand;

from FancyLogin_loginForm.php file to fancy_login.module file.

5. Deleted library

use Drupal\Core\Ajax\AppendCommand;

from FancyLogin_loginForm.php file.

6. Moved function ser_pass_ajax_callback from FancyLogin_passForm.php file to fancy_login.module

file.

7. Moved library

use Drupal\lightbox_login\Ajax\lightboxLoginClosePopupCommand;

from FancyLogin_passForm.php file to fancy_login.module file.

8. In folder fancy_login/src/Plugin/Block

a) Added rows

/**

* @file

* Contains \Drupal\fancy_login\Plugin\Block\FancyLoginBlock.

*/

to FancyLoginBlock.php file.

b) Changed code from

$GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin'])

to

\Drupal::currentUser()->isAnonymous()

in build function in FancyLoginBlock.php file.

9. In folder fancy_login/src/Controller

a) Deleted function

drupal_process_attached($form) in ajax_callback function in FancyLoginController.php file.

b) Changed row

$scripts = _drupal_add_js();

to

$scripts = drupal_js_defaults();

in ajax_callback function in FancyLoginController.php file.

10. In fancy_login.module file

a) in functions user_login_block_ajax_callback and user_pass_ajax_callback

changed argument to no longer pass by reference from

array &$form

to

$form

b) in functions user_login_block_ajax_callback and user_pass_ajax_callback

changed rows

$messages = array('#theme' => 'status_messages');

$messages = drupal_render($messages);

to

$renderer = \Drupal::service('renderer');

$messages = array('#type' => 'status_messages');

$messages = $renderer->renderRoot($messages);

c) in function user_login_block_ajax_callback

changed row

$response->addCommand(new AppendCommand('#lightbox_login_user_login_block_wrapper',

$messages));

to

$selector = '#fancy_login_user_login_block_wrapper';

...

$response->addCommand(new Ajax\AppendCommand($selector, $messages));

d) in function user_pass_ajax_callback

changed row

$response->addCommand(new AppendCommand('#lightbox_login_user_pass_block_wrapper',

$messages));

to

$selector = '#lightbox_login_user_pass_block_wrapper';

...

$response->addCommand(new Ajax\AppendCommand($selector, $messages));

e) in function fancy_login_page_bottom

changed row

GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin'])

to

\Drupal::currentUser()->isAnonymous()

f) in function fancy_login_page_bottom

changed row

$login_path = \Drupal::service('path.alias_manager')->getAliasByPath('user/login');

to

$login_path = \Drupal::service('path.alias_manager')->getAliasByPath('/user/login');

g) in function fancy_login_page_bottom

changed row

'callback' =>

'Drupal\lightbox_login\Form\lightboxLogin_loginForm::user_login_block_ajax_callback',

to

'callback' => 'user_login_block_ajax_callback',

h) in function fancy_login_page_bottom

changed row

'callback' => 'Drupal\lightbox_login\Form\lightboxLogin_passForm::user_pass_ajax_callback',

to

'callback' => 'user_pass_ajax_callback',

11. In folder fancy_login/js in file fancy_login.js

changed all methods to use each in JQuery

$("body").once("fancy-login-init", function () {

to

$("body").once("fancy-login-init").each(function () {

All of these changes were necessary to the module began to work.

Hope after we got this official D 8 release – we will not get such global changes in future.

Thanks.

Continuing with our posts, on our WordPress/Drupal to mobile app conversion software, here is a more technical post explaining how we integrated the Facebook SDK into our wrapper technology tallow native single sign on from your app homescreen.

The steps are as follows.
1. Download SDK
2. Create Facebook App
3. App Settings
4. Add SDK
5. Configure Xcode
6. Connect Application Delegate
7. Add App Events

1) Download the SDK and unzip the archive to ~/Documents/FacebookSDK.

2) If your app is not yet registered with Facebook and has an app ID, you should create it. You can share an app ID across platforms from this link :- https://developers.facebook.com/?advanced_app_create=true

3) 1. Select Settings in App Dashboard.

  1. Click Add Platform and choose iOS.
    2. Then provide your Bundle Identifier in the Bundle ID field.
    3. Enable Single Sign On.
    4. Click Save Changes


4) To add the SDK in Xcode:

  1. Open ~/Documents/FacebookSDK
    2. Drag the FBSDKCoreKit.framework to Frameworks in Project Navigator. Create a new group Frameworks if it does not exist.
    3. Choose Create groups for any added folders.
    4. Deselect Copy items into destination group’s folder. This references the SDK where you installed it rather than copying the SDK into your app.

The SDK automatically loads its framework and resource dependencies.

5) Now configure the .plist for your project:

  1. In Xcode right-click your .plist file and choose “Open As Source Code”.
    2. Copy & Paste the XML snippet into the body of your file (<dict>…</dict>).
    3. Replace:

fb{your-app-id} with your Facebook App ID and the prefix fb. E.g.: fb123456.
{your-app-id} with your Facebook App ID.
{your-app-name} with the Display Name you configured in the app dashboard.

 

6) To post process the results from Facebook Login or Facebook Dialogs (or any action that requires switching over to the native Facebook app or Safari) you need to connect your AppDelegate to theFBSDKApplicationDelegate. In your AppDelegate.m add:

– (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
   return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                         openURL:url
                                               sourceApplication:sourceApplication
                                                      annotation:annotation];
}



7) Add App Events

The SDK is installed and set up. The easiest way to test your implementation is to add App Events to your app. App Events help you understand the makeup of people who engage with your app. This is done by logging events via one of 14 predefined events such as ‘added to cart’ in a commerce app or ‘level achieved’ in a game, or any custom events you can define.
Log App Activations
A basic example is to log app activations. To do so add the following code snippet to yourAppDelegate.m:

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

   [FBSDKAppEvents activateApp];
}


After that while clicking on some button add this code :—

 

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
   [login logInWithReadPermissions:@[@”email”] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
       if (error) {
           // Process error
       } else if (result.isCancelled) {
           // Handle cancellations
       } else {
           // If you ask for multiple permissions at once, you
           // should check if specific permissions missing
           if ([result.grantedPermissions containsObject:@”email”]) {
               // Do work
                                      
               } else
               {
                   NSLog(@”Not granted”);
               }
               
               NSLog(@”Response:: %@”, result.grantedPermissions);
               [FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
           }
       }
   }];
   


Congratulations Facebook integration is now complete!. You can create API’s and add your own logic for FB integration in any app.


  • Alex was a great asset to help finish our Drupal development project. He was knowledgeable, flexible and always tried to find a solution that would work in our current environment. He delivered on time and was always open to making additional modifications when needed. Because of his skills we were able to launch on time and within budget. I would recommend him to any company as he is easy to work with and gets the job done. Thanks Alex! ~Internet Society

  • Alex handles all of the back office details of our somewhat complex website system. He is able to manage the sites as well as help out when we need to develop something new. He’s willing and able to teach staff how to do things we need to understand to handle our content management systems in both WordPress and Drupal. He also is on call pretty much round the clock should any system have trouble. So happy to have him on our team. ~Pratt Center

  • Alex is Drupal master with top notch skills and seasoned experience. He is focused, dedicated and is a great team player. A huge asset to any dev team. And a mean banjo player. ~Wanderlust Festival

 

Contact

office: (212)-658-1447 | cell: (914)-715-8862 | alex@freeenergymedia.com

Name
Email
Message

Message sent, Thanks!
Error! Please validate your fields.
Copyright 2015 Free Energy Media