Customizing SMF > Bridges and Integrations

Integration hooks - Symfony Framework

(1/3) > >>

krator:
Hello everyone.

I have started to use SMF and I would like to integrate it with a Framework based in Symfony. So, I readed this wiki Integrating SMF.
Here 3 cases are described. My scenario is the two, so that i readed this: Integration hooks.

Futhermore, i found this topic: New tools to help integrating SMF with something else, with an integration hook skeleton.

Well, i added in my index.php (SMF) this file (integration hook skeleton) and i checked that is working (the functions was reached sucessfully, hurray  ;D).

Ok, second step...initializate Symfony and check that I can use it...
Well, if in my `smf_2_integration_hooks.php`, at the first i put the code:

--- Code: ---use Symfony\Component\HttpFoundation\Request;
use Zikula\UsersModule\Entity\RepositoryInterface\UserRepositoryInterface;
use Zikula\UsersModule\Entity\UserEntity;

require 'lib/bootstrap.php';
$request = Request::createFromGlobals();
$kernel->boot();
$container = $kernel->getContainer();
$userRepository = $container->get('zikula_users_module.user_repository');
$zkUser = $userRepository->findOneBy(['uname' => 'krator']);
var_dump($zkUser);
exit();

--- End code ---

This code is working and I have the user entity (hurray again!). Ok, but this is neccesary in each function, so, I generate my custom function:

--- Code: ---function zikula_load_core()
{
require 'lib/bootstrap.php';
$request = Request::createFromGlobals();
$kernel->boot();
$container = $kernel->getContainer();
return $container;
}

--- End code ---

Well, it's the time of test a function, ex: logoout

--- Code: ---function smf_logout_function($memberName)
{
$container = zikula_load_core();
$userRepository = $container->get('zikula_users_module.user_repository');
$zkUser = $userRepository->findOneBy(['uname' => 'krator']);
var_dump($zkUser);
exit();
}

--- End code ---

But this it's not working (not hurray  :( ). In fact, this line for "instanciate/load" the Service "zikula_users_module.user_repository" not return the service (userRepository is empty). What's wrong? Why is working outside of functions and here not?

Thanks.

Suki:
Hi, what exactly are you trying to do? as in, whats the final goal of this integration?  Are you integrating your framework on SMF or SMF on our framework?

krator:
Hello Suki.

Im trying integrate the symfony framework on SMF. As I indicated in the topic, scenario 2 of this link (Integration hooks can be used if you want SMF to be the primary system, but you need to pass data to another script in the middle of an SMF process (i.e. new user signing up in SMF registration -> pass the user data to another script, run some more processes on that script, and then return to SMF's routines)).
This is the reason because Im using integration hooks.

Thanks for your anwer.

Suki:
Whats does smf_2_integration_hooks.php looks like? can you attach it here?

krator:
Hello Suki.

As I mentioned in the first post, this php was extracted from here (first post). It's a skeleton, I'm going to extract the basics of the file:


--- Code: ---<?php
//define the integration functions, comment out the ones you don't need
define('SMF_INTEGRATION_SETTINGS',
    serialize( array(
        'integrate_pre_load'           => 'smf_pre_load_function',
        'integrate_activate'           => 'smf_activate_function',
    'integrate_change_member_data' => 'smf_change_member_data_function',
    'integrate_create_topic'       => 'smf_create_topic_function',
    'integrate_delete_member'      => 'smf_delete_member_function',
    'integrate_exit'               => 'smf_exit_function',
    'integrate_fix_url'            => 'smf_fix_url_function',
        'integrate_load_theme'         => 'smf_load_theme_function',
    'integrate_login'              => 'smf_login_function',
    'integrate_logout'             => 'smf_logout_function',
    'integrate_outgoing_email'     => 'smf_outgoing_email_function',
    'integrate_personal_message'   => 'smf_personal_message_function',
    'integrate_redirect'           => 'smf_redirect_function',
    'integrate_register'           => 'smf_register_function',
    'integrate_reset_pass'         => 'smf_reset_pass_function',
    'integrate_validate_login'     => 'smf_validate_login_function',
        'integrate_verify_password'    => 'smf_verify_password_function',
        'integrate_verify_user'        => 'smf_verify_user_function',
        'integrate_whos_online'        => 'smf_whos_online_function',
    ))
);

...
functions...
...
function smf_logout_function($memberName)
{
  ...
}

?>

--- End code ---

So, if i put the code before "define", work, but if i put the code inside a function, dont work.

Thanks.

Navigation

[0] Message Index

[#] Next page

Go to full version