Enhancement(機能追加・改善) #4183
Shinichi Urabe さんが7年以上前に更新
h3. 概要 JS から app_url_for, url_for などのヘルパーの結果を問い合わせる機構の作成 https://symfony.com/doc/current/bundles/FOSJsRoutingBundle/usage.html にあるような機能がほしい h3. 仕様 h4. opUrl.app_url_for Symfony2 で使える FOSJsRoutingBundle に存在するような機能がほしい h5. jsDoc Ex. <pre> <code class="javascript"> /** * method app_url_for(). * * @param {strina} application ex: pc_frontend, api ... * @param {string} internalUri 'module/action' or '@rule' of the action * @param {boolean} absolute return absolute path? * @param {object} callback {success: function(result) {}, error: function(error) {}} */ </code> Routing.url_for('obj_member_profile', { id: 10 }); </pre> h5. code example. <pre> <code class="javascript"> // no problem url. opUrl.app_url_for( 'api', '@homepage', false, { 'success': function (url) { console.log(url); } } ); will result in /member/10 // -> /api.php/ // invalidUrl opUrl.app_url_for( 'api', '@invalidUrl', false, Routing.app_url_for('mobile_frontend', 'obj_friend_unlink', { 'success': function (url) { console.log(url); id: 10 }, 'error': function(xhr, textStatus, errorThrown) { console.log(xhr, textStatus, errorThrown); } } true); ); // -> xhr object, status, error </code> will result in http://example.com/mobile_frontend.php/friend/unlink/10 </pre> h4. opUrl.url_for for pc_frontend. h5. jsDoc <pre> <code class="javascript"> /** * method app_url_for(). * * @param {string} internalUri 'module/action' or '@rule' of the action * @param {boolean} absolute return absolute path? * @param {object} callback {success: function(result) {}, error: function(error) {}} */ </code> </pre> h5. code example. <pre> <code class="javascript"> // no problem url. opUrl.url_for( '@homepage', true, { 'success': function (url) { console.log(url); } } ); // -> http://example.com/ // invalidUrl opUrl.url_for( '@invalidUrl', true, { 'success': function (url) { console.log(url); }, 'error': function(xhr, textStatus, errorThrown) { console.log(xhr, textStatus, errorThrown); } } ); // -> xhr object, status, error </code> </pre>